Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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