Functions · 2.5
Recursion
All lessons are open — jump whenever you need.
Functions can call themselves:
fn factorial(n: int) -> int {
if n <= 1 { return 1 }
return n * factorial(n - 1)
}
print(factorial(5)) // 120Goal: Implement fibonacci(n) recursively. fibonacci(10) should return 55.
lesson-2-5.zolo
Program output
Run the code to see the output