#K56292. Partitions of an Integer into Consecutive Sums
Partitions of an Integer into Consecutive Sums
Partitions of an Integer into Consecutive Sums
Given a positive integer n, determine the number of ways to represent n as the sum of two or more consecutive positive integers.
For example, when n = 9, there are two valid representations:
- 4 + 5 = 9
- 2 + 3 + 4 = 9
The consecutive sequence can be represented by the formula: \( n = a + (a+1) + \cdots + (a+k) \), where a is the starting integer and the sequence length is \(k+1\) with \(k \ge 1\). Note that single term representation is not allowed.
This problem challenges you to implement a solution that computes the number of such partitions for each test case.
inputFormat
The input consists of multiple test cases. Each test case is given on a separate line containing a positive integer n (\(1 \leq n \leq 10^9\)). The input terminates with a line containing a single 0, which should not be processed.
outputFormat
For each test case, output a single line with one integer: the number of ways to partition n into the sum of two or more consecutive positive integers.
## sample9
15
10
0
2
3
1
</p>