func fib_iter(n) {
var (a, b) = (0, 1)
{ (a, b) = (b, a+b) } * n
return a
}
func fib_rec(n) {
n < 2 ? n : (__FUNC__(n-1) + __FUNC__(n-2))
}
Recursive with memoization
func fib_mem (n) is cached {
n < 2 ? n : (__FUNC__(n-1) + __FUNC__(n-2))
}
func fib_closed(n) {
define S = (1.25.sqrt + 0.5)
define T = (-S + 1)
(S**n - T**n) / (-T + S) -> round
}