FunctionRacerProblemsRace

Sum of Divisors

BeginnerMathPython, JavaScript, TypeScript, Java, C++

Return the sum of all positive divisors of n, including 1 and n.

Example 1

n 6
returns 12

1 + 2 + 3 + 6 = 12.

Example 2

n 7
returns 8

1 + 7 = 8.

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