Created
November 27, 2013 06:33
-
-
Save harrisgca/7671501 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
tester = [1,2] #creating the initial array | |
my_sum = 0 #have to declare my_sum here | |
until my_sum >= 4000000 do | |
my_sum = tester[-1] + tester[-2] | |
tester << my_sum | |
end #adds the last two items in the array to each other | |
tester.delete_if &:odd? | |
gr_total = tester.inject (:+) | |
puts "The answer to Problem 2 on projecteuler.net is #{gr_total}." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment