Skip to content

Instantly share code, notes, and snippets.

@wavebeem
Created March 10, 2011 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wavebeem/863709 to your computer and use it in GitHub Desktop.
Save wavebeem/863709 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# Ruby ruby ruby!
#
def fibo(a=1, b=1)
n = 0
yield 0, a
yield 1, b
loop do
a, b = b, a + b
n += 1
yield n, b
end
end
fibo do |n, x|
exit if n > 100_000
puts "#{n} => #{x}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment