Created
October 23, 2014 18:32
-
-
Save carlwiedemann/3e6c0a87127729f6e32b to your computer and use it in GitHub Desktop.
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
s = 0 | |
# First two Fibbonacci terms | |
f_last = 1 | |
f = 1 | |
while f < 4 * 10**6 | |
# Sum evens | |
s += f % 2 == 0 ? f : 0 | |
# Next Fibbonacci number | |
f_new = f + f_last | |
f_last = f | |
f = f_new | |
end | |
puts s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment