MCPcopy Create free account
hub / github.com/geekcomputers/Python / getFibonacciIterative

Function getFibonacciIterative

fibonacci.py:7–18  ·  view source on GitHub ↗

Calculate the fibonacci number at position n iteratively

(n: int)

Source from the content-addressed store, hash-verified

5
6
7def getFibonacciIterative(n: int) -> int:
8 """
9 Calculate the fibonacci number at position n iteratively
10 """
11
12 a = 0
13 b = 1
14
15 for _ in range(n):
16 a, b = b, a + b
17
18 return a
19
20
21def getFibonacciRecursive(n: int) -> int:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected