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 = 15
Output:4
Explanation:

15 = 15 = 7+8 = 4+5+6 = 1+2+3+4+5.

Input:n = 9
Output:3
Explanation:

9 = 9 = 4+5 = 2+3+4. There are 3 ways to write 9 as a sum of consecutive positive integers.

Input:n = 21
Output:4
Explanation:

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⁹

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!