Ways as a Run of Numbers
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
1 <= n <= 10**9
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Math problems
- Alternating Digit SumBeginner
- Armstrong NumberBeginner
- Base K to DecimalBeginner
- Collatz StepsBeginner
- Count DivisorsBeginner
- Decimal to Binary StringBeginner
- Digit Sum in Base KBeginner
- Digital RootBeginner