Created
November 28, 2015 02:56
-
-
Save notmarkmiranda/e1730da1a3be95714631 to your computer and use it in GitHub Desktop.
Euler - 002.rb
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
current = 1 | |
previous = 0 | |
sum = 0 | |
new = 0 | |
while new <= 4000000 do | |
new = current + previous | |
if (new % 2 == 0) | |
sum += new | |
end | |
previous = current | |
current = new | |
end | |
puts sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment