FunctionRacerProblemsRace

Sum of Multiples

BeginnerMathPython, JavaScript, TypeScript, Java, C++

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems