Created
May 10, 2011 12:47
-
-
Save maehrm/964407 to your computer and use it in GitHub Desktop.
fiberを使ってフィボナッチ数列
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fibo | |
a, b = 0, 1 | |
Fiber.new do | |
loop do | |
Fiber.yield b | |
a, b = b, a + b | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment