Sums of consecutive positive integers
Filename: Consecutive.java
Input file: consecutive.in
Consider the following positive integers: 5, 25, 29, 41, and 100. Each of these numbers can be expressed as a sum of n consecutive positive integers, where n > 1, as follows:
5 = 2 + 3
25 = 3 + 4 + 5 + 6 + 7
29 = 14 + 15
41 = 20 + 21
100 = 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16
1; 000; 000 = 7; 749 + … + 7; 876
Note that the decomposition is not unique. For example, observe that 25 is also equal to 12 + 13. However, 8, 32, and 1,024 are examples of numbers that cannot be expressed as sums of consecutive positive integers.
Your task is to determine if a positive integer can be expressed as a sum of consecutive positive integers, and to display the decomposition if that is possible.
INPUT FORMAT
The input consists of one or more lines with each line consisting of a positive integer.
OUTPUT FORMAT
The output consists of one or more lines with each line consisting of the given positive integer followed by the _rst and last term of its decomposition into a sum of consecutive positive integers. If the decomposition is not possible, then the line should display \n is not possible.", where n is the given positive integer. (Note: Any among the correct decompositions is acceptable).
SAMPLE INPUT
5
25
29
32
100
1000000
SAMPLE OUTPUT
5 2 3
25 3 7
29 14 15
32 is not possible.
100 9 16
1000000 7749 7876