Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This code produces the wrong answer and I don't know why. It also is bloated code; I've seen other people's 1 line solution LOL edit: 3rd time was the charm!!!
closer = #create array to hold numbers
for i in 1..999 do #populating array with multiples of 3 and 5
if i % 3 == 0
closer << i
i % 5 == 0
closer << i
closer_sum = closer.inject (:+) #compute sum of all numbers in array
puts ""
puts "The answer to Problem 1 on is #{closer_sum}."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.