Functions can call themselves:
fn factorial(n: int) -> int { if n <= 1 { return 1 } return n * factorial(n - 1) } print(factorial(5)) // 120
Goal: Implement fibonacci(n) recursively. fibonacci(10) should return 55.
fibonacci(n)
fibonacci(10)
55
Run the code to see the output
9 results