mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-03 05:10:55 +00:00
18 lines
398 B
Plaintext
18 lines
398 B
Plaintext
/* fibonacci sequence */
|
|
/**
|
|
* fib(n): calculate the fibonacci sequence.
|
|
* @input n the number to calculate fibonacci for
|
|
* @result the value of the fibonacci sequence for the number
|
|
*/
|
|
fib = { n in
|
|
if n == 0 // if n is zero, return zero
|
|
then 0
|
|
else if n == 1 // if n is one, return one
|
|
then 1
|
|
else fib(n - 1) + fib(n - 2)
|
|
}
|
|
|
|
// result of fib(20)
|
|
result = fib(20)
|
|
println(result)
|