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