Calculate the fibonacci number at position n iteratively
(n: int)
| 5 | |
| 6 | |
| 7 | def 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 | |
| 21 | def getFibonacciRecursive(n: int) -> int: |
no outgoing calls
no test coverage detected