Skip to content

Instantly share code, notes, and snippets.

@bjhaid
Created October 8, 2013 22:53
Show Gist options
  • Save bjhaid/6893187 to your computer and use it in GitHub Desktop.
Save bjhaid/6893187 to your computer and use it in GitHub Desktop.
Fibonacci number in ruby
fib = Enumerator.new do |y|
j,i = 0,1
loop do
y.yield j
x = i
i += j
j = x
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment