/// Returns the nth Fibonacci number. Correct, but very slow.
int fib(int n) {
    if (n <= 1) {
        return n;
    }
    return fib(n - 1) + fib(n - 2);
}

void main() {
    for (int i = 0; i < 10; i++) {
        IO.print(fib(i) + " ");
    }
    IO.println();
}

// From Groundwork, chapter 12 (ch12-recursion-and-problem-solving), box 7.
// This example is from Groundwork, licensed CC BY-NC-SA 4.0.
// Run with: java ch12_07.java
