aboutsummaryrefslogtreecommitdiff
path: root/examples/fib.micro
blob: efd75178d3c1f139617feb5de417faee4ab6679f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//
// Using recursive tail call optimizations
//

def fib(n number, acc1 number, acc2 number) number {
    if n == 0 {
        return acc1;
    } else {
        if n == 1 {
            return acc2;
        } else {
            return fib(n - 1, acc2, acc1 + acc2);
        }
    }
}

println("fib 90: ", fib(90, 0, 1));