Created
July 24, 2012 11:23
-
-
Save yuuki/3169441 to your computer and use it in GitHub Desktop.
euler2
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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
fib = Enumerator.new do |y| | |
a, b = 0, 1 | |
while b < 4000000 do | |
y << b if b % 2 == 0 | |
a, b = b, a + b | |
end | |
end | |
puts fib.inject{ |sum, n| sum + n } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment