You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
183 B
18 lines
183 B
9 years ago
|
/*
|
||
|
* Fibonacci
|
||
|
*/
|
||
|
|
||
|
fib = fn (x) {
|
||
|
if x < 2 {
|
||
|
x
|
||
|
} else {
|
||
|
self(x - 2) + self(x -1)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
mut i = 0
|
||
|
while i < 30 {
|
||
9 years ago
|
puts("{i}: {fib(i)}")
|
||
9 years ago
|
i = i + 1
|
||
|
}
|