FastPrepFibonacci Number

Fibonacci Number

Bloomberg LP logoBloomberg LP● EasyNEW GRADPHONE SCREEN
Learn

Problem statement

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

Function

fibonacci(n: int) → long

Examples

Example 1

n = 2return = 1

F(2)=F(1)+F(0)=1.

Example 2

n = 10return = 55

The tenth Fibonacci number is 55.

Constraints

  • 0 <= n <= 91.

More Bloomberg LP problems

See Bloomberg LP hiring insights
public long fibonacci(int n) {
  // Write your code here.
}
n2
expected1
Checking account…