Skip to content

Instantly share code, notes, and snippets.

@harrisgca
Created November 27, 2013 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harrisgca/7671501 to your computer and use it in GitHub Desktop.
Save harrisgca/7671501 to your computer and use it in GitHub Desktop.
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