FastPrepThe Nth Number in the Fibonacci Sequence
Problems/The Nth Number in the Fibonacci Sequence

The Nth Number in the Fibonacci Sequence

Capital One logoCapital One● EasyFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A 2017 Capital One software engineer report from San Francisco mentions a coding task about the Fibonacci sequence, where the function has to produce one chosen entry of it. The process had phone screens, a remote technical interview and a half-day onsite.

The report does not say which round asked it, where the sequence starts or how big n gets. Here F(0) = 0 and F(1) = 1, and n goes up to 45 so the answer fits a 32-bit integer. These are our choices.

Our version is about 90% the same as the reported question.

Position 0 of the Fibonacci sequence holds 0, position 1 holds 1, and from position 2 on each entry adds up the two entries just before it. Return the entry at position n as an int.

Function

fibonacci(n: int) → int

Examples

Example 1

n = 7return = 13

Position 5 holds 5 and position 6 holds 8, so position 7 holds their sum, 13.

Example 2

n = 0return = 0

The sequence starts at position 0 with the value 0.

Example 3

n = 40return = 102334155

The sequence grows quickly: position 40 is already over a hundred million, 102334155.

Constraints

  • 0 <= n <= 45

More Capital One interview questions

  • Count Records Present in A but Not BPHONE SCREEN · Seen Oct 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
  • Maximum Subarray SumPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2025
  • Ten-Pin Bowling Frame ScoresPHONE SCREEN · Seen Nov 2023
  • Min StackPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2023
  • Invert a Binary TreePHONE SCREEN · Seen Dec 2020
  • Count How Often a Word Appears in a ParagraphPHONE SCREEN
  • In-Memory File System With Directory SizesPHONE SCREEN · ONSITE INTERVIEW
  • Pick the K Nearest Grid Points to (0, 0)PHONE SCREEN · ONSITE INTERVIEW
  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Biased Coin: Probability of Exactly h HeadsAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Dice Sum That Is a Multiple of mSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
  • Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Climbing StairsAmazon · ONSITE INTERVIEW
  • Count Staircase WaysGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Climbing StairsAMD · ONSITE INTERVIEWAMD interview questions
  • Climb Stairs with One, Two, or Three StepsAgoda · ONSITE INTERVIEWAgoda interview questions
  • Climbing StairsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Climbing StairsGoogle · PHONE SCREENGoogle interview questions
  • Count Routes Through a City GridIMC Trading · PHONE SCREENIMC Trading interview questions

Capital One interview experiences

  • Capital One Experienced Engineer Power Day and OA: 6 Experiences
  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
  • Capital One TDP Agentic Power Day: 25 Experiences (Part 1 of 2)
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public int fibonacci(int n) {
        // Write your code here.
    }
}
Checking account…