15 lines
228 B
Text
15 lines
228 B
Text
# This program computes the fibonacci numbers using recursion (O(2^n))
|
|
# It is very slow
|
|
fn fib(x: number) number {
|
|
if x <= 1 {
|
|
x
|
|
} else {
|
|
fib(x - 1) + fib(x - 2)
|
|
}
|
|
}
|
|
|
|
n := 0
|
|
while n < 100 {
|
|
println(fib(n))
|
|
n = n + 1
|
|
}
|