phasm/examples/fib.py
Johan B.W. de Vries b28df7fa74 Fix: Could not both export and use function
Added HTML pages for fib example
2022-06-24 18:52:43 +02:00

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)