#520 · Loops · Beginner · Find and fix · 25 XP · about 3 min
sum_multiples(n) should add up every whole number from 1 to n, including n itself, that is divisible by 3 or by 5.
The code in the editor has a bug. It gives the right answer for 7, but sum_multiples(10) comes out as 23 instead of 33.
sum_multiples(7) # returns 14 sum_multiples(10) # returns 33 sum_multiples(1) # returns 0
Up to 10, the numbers divisible by 3 or 5 are 3, 5, 6, 9 and 10, which add up to 33.
n is a whole number, 0 or more.
First solves only, ranked by stars and then time.