Sum of Multiples
Return the sum of all the numbers from 1 to n (inclusive) that are divisible by 3, by 5, or by 7. Each number is added once, even if it qualifies for several reasons.
Example 1
n 10
returns 40
3 + 5 + 6 + 7 + 9 + 10 = 40.
Constraints
1 <= n <= 1000
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.