input: positive integer 'n' returns the n-th fibonacci term , indexing by 0
(n)
| 614 | |
| 615 | |
| 616 | def fib(n): |
| 617 | """ |
| 618 | input: positive integer 'n' |
| 619 | returns the n-th fibonacci term , indexing by 0 |
| 620 | """ |
| 621 | |
| 622 | # precondition |
| 623 | assert isinstance(n, int) and (n >= 0), "'n' must been an int and >= 0" |
| 624 | |
| 625 | tmp = 0 |
| 626 | fib1 = 1 |
| 627 | ans = 1 # this will be return |
| 628 | |
| 629 | for i in range(n - 1): |
| 630 | tmp = ans |
| 631 | ans += fib1 |
| 632 | fib1 = tmp |
| 633 | |
| 634 | return ans |
nothing calls this directly
no outgoing calls
no test coverage detected