Consecutive Numbers Sum
Given an integer n, return the number of ways you can write n as the sum of consecutive positive integers.
Example 1
Input
n = 5Output
2The number 5 can be written as 5 and as 2 + 3, so there are 2 ways.
Example 2
Input
n = 9Output
3The number 9 can be written as 9, 4 + 5, and 2 + 3 + 4, so there are 3 ways.
Constraints
- 1 <= n <= 10^9