7 lines
150 B
Text
7 lines
150 B
Text
cache = hash.new
|
|
|
|
fibonacci = { x |
|
|
true? cache.key?(x)
|
|
{ cache[x] }
|
|
{true? x < 2, x, { cache[x] = fibonacci(x - 1) + fibonacci(x - 2) }}
|
|
}
|