phasm/examples/fib.py
Johan B.W. de Vries 0da309a280 Remove old code
2022-06-19 17:04:20 +02:00

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)