FunctionRacerProblemsRace

Ways as a Run of Numbers

HardMathPython, JavaScript, TypeScript, Java, C++

Return how many ways n can be written as a sum of one or more whole numbers in a row, all positive.

9 has three ways: 9, 4 + 5 and 2 + 3 + 4.

Example 1

n 9
returns 3

9, 4 + 5 and 2 + 3 + 4.

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