20 lines
300 B
Python
20 lines
300 B
Python
def helper(n: i64, a: i64, b: i64) -> i64:
|
|
if n < 1:
|
|
return a + b
|
|
|
|
return helper(n - 1, a + b, a)
|
|
|
|
@exported
|
|
def fib(n: i64) -> i64:
|
|
if n == 0:
|
|
return 0
|
|
|
|
if n == 1:
|
|
return 1
|
|
|
|
return helper(n - 1, 0, 1)
|
|
|
|
@exported
|
|
def testEntry() -> i64:
|
|
return fib(40)
|