mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2025-01-22 21:35:29 +00:00
18 lines
181 B
Plaintext
18 lines
181 B
Plaintext
|
/*
|
||
|
* Fibonacci
|
||
|
*/
|
||
|
|
||
|
fib = fn (x) {
|
||
|
if x < 2 {
|
||
|
x
|
||
|
} else {
|
||
|
self(x - 2) + self(x -1)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
mut i = 0
|
||
|
while i < 30 {
|
||
|
pp("{i}: {fib(i)}")
|
||
|
i = i + 1
|
||
|
}
|