MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / fibonacci

Function fibonacci

dynamic_programming/fast_fibonacci.py:13–21  ·  view source on GitHub ↗

return F(n) >>> [fibonacci(i) for i in range(13)] [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]

(n: int)

Source from the content-addressed store, hash-verified

11
12
13def fibonacci(n: int) -> int:
14 """
15 return F(n)
16 >>> [fibonacci(i) for i in range(13)]
17 [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
18 """
19 if n < 0:
20 raise ValueError("Negative arguments are not supported")
21 return _fib(n)[0]
22
23
24# returns (F(n), F(n-1))

Callers 1

fast_fibonacci.pyFile · 0.70

Calls 1

_fibFunction · 0.85

Tested by

no test coverage detected