FastPrepFibonacci Number
Problems/Fibonacci Number

Fibonacci Number

JP Morgan Chase logoJP Morgan Chase● EasyINTERNNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a JP Morgan Chase onsite interview, for interns or new grads. The report asks for recursive and dynamic-programming Fibonacci code. It does not give the index convention or a limit. Our version is about 95% the same as the reported task.

Return the Fibonacci number F(n), where F(0) = 0, F(1) = 1, and F(n) = F(n - 1) + F(n - 2) for n >= 2.

Practice both a recursive solution and a dynamic-programming solution. The editorial shows memoized recursion and an iterative solution using the same recurrence.

Function

fibonacci(n: int) → int

Examples

Example 1

n = 5return = 5

The sequence from index 0 through 5 is 0, 1, 1, 2, 3, 5.

Example 2

n = 0return = 0

The base definition gives F(0) = 0.

Constraints

  • 0 <= n <= 45

More JP Morgan Chase Onsite Interview questions

  • LFU CacheONSITE INTERVIEW · Seen Nov 2026
  • LRU CacheONSITE INTERVIEW · Seen Nov 2026
  • Employees Above Average SalaryONSITE INTERVIEW · Seen Sep 2026
  • Highest-Earning Employees By DepartmentONSITE INTERVIEW · Seen Sep 2026
  • K Largest Integers in Descending OrderONSITE INTERVIEW · Seen Aug 2026
  • Tile a Three-Row Board with DominoesONSITE INTERVIEW · Seen Jan 2026
  • Two SumONSITE INTERVIEW · Seen Nov 2025
  • Intersection of Two ListsONSITE INTERVIEW · Seen Jan 2025
  • Maximum Subarray SumONSITE INTERVIEW · Seen Jan 2025
  • Integrate a Sampled FunctionONSITE INTERVIEW · Seen Nov 2024

Similar questions at other companies

  • Fibonacci with Input ValidationMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions
  • Count Complete Tic-Tac-Toe GamesDecagon · PHONE SCREEN · ONSITE INTERVIEWDecagon interview questions
  • Scramble StringExpedia · ONSITE INTERVIEWExpedia interview questions
  • Validate a Palindrome After Limited DeletionsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Binary Tree Maximum Path SumGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Recursive Task Worker with MemoizationCitadel · ONSITE INTERVIEWCitadel interview questions
  • Wildcard Pattern MatchingMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Every Result of Grouping an ExpressionC3.ai · ONSITE INTERVIEWC3.ai interview questions
  • Maximum Subarray SumStraive · OA
  • Edit DistanceAstrotalk · PHONE SCREEN

Interview reports that mention this question

  • JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
  • JPMorgan Chase Intern Campus Rounds: 4 Experiences (Part 2 of 5)

JP Morgan Chase interview experiences

  • JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
  • JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
  • JP Morgan Chase Data and AI Intern Superday: 11 Experiences
  • JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)
All JP Morgan Chase interview questionsSee JP Morgan Chase hiring insights
Saved
class Solution {
    public int fibonacci(int n) {
        // Write your code here.
    }
}
Checking account…