I want to do the sums of multiples of 3 or 5 untill 1000 but I got a problems of unexpected end
but I dont understand why
def multiple_of_3_or_5(nb)
if nb % 3 == 0 || nb % 5 == 0
return true
else
return false
end
end
def perform
i = 1
res = 0
while i <= 1000
if multiple_of_3_or_5(i)
res += i
end
i++
end
puts res
end
perform
I got those errors in iTerm :
multiples.rb:17: syntax error, unexpected `end'
multiples.rb:21: syntax error, unexpected end-of-input, expecting `end'
But when I remove the end
l.17 I got this
multiples.rb:18: syntax error, unexpected local variable or method, expecting `do' or '{' or '(' puts res
Can anyone explain my why and how to do for this programs works?