Description
Given a positive integer n, return the number of ways to write n as a sum of consecutive positive integers (at least 2 numbers).
Examples
Input:
n = 15Output:
4Explanation:
15 = 15 = 7+8 = 4+5+6 = 1+2+3+4+5.
Input:
n = 9Output:
3Explanation:
9 = 9 = 4+5 = 2+3+4. There are 3 ways to write 9 as a sum of consecutive positive integers.
Input:
n = 21Output:
4Explanation:
21 = 21 = 10+11 = 6+7+8 = 1+2+3+4+5+6. There are 4 ways to write 21 as a sum of consecutive positive integers.
Constraints
- •
1 ≤ n ≤ 10⁹