Sha256: c02a85bc2f349a6893593330891e11cc5b45c51687b5a0c670b871c5a1dc3f14
Contents?: true
Size: 352 Bytes
Versions: 1
Compression:
Stored size: 352 Bytes
Contents
def fibonacci(n:int) return n if n < 2 fibPrev = 1 fib = 1 3.upto(Math.abs(n)) do oldFib = fib fib = fib + fibPrev fibPrev = oldFib end fib * (n<0 ? int(Math.pow(n+1, -1)) : 1) end puts fibonacci 1 puts fibonacci 2 puts fibonacci 3 puts fibonacci 4 puts fibonacci 5 puts fibonacci 6 puts fibonacci 7
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mirah-0.0.8-java | examples/rosettacode/fibonacci.mirah |