Skip to content
Course map | Lesson 5 of 5

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)) // 120

Goal: Implement fibonacci(n) recursively. fibonacci(10) should return 55.

lesson-2-5.zolo
Program output

Run the code to see the output

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br