public
Last active

Fibonacci with Inject!

  • Download Gist
gistfile1.rb
Ruby
1 2 3
def fib(n)
(0..n).inject([1,0]) { |(a,b), _| [b, a+b] }[0]
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.