the question is:
please input a positive integer that It is the sum of n(n>=2) consecutive integers.and please output all of the sequence of consecutive integers.A line for each sequence. Integers separated by spaces between.Each sequence from small to large.
e.g
input: 21
21=1+2+3+4+5+6
21=6+7+8

so you should output:
1 2 3 4 5 6
6 7 8
...............

I would if I change the conditions. let sequence to meet small to large.Not a continuous sequence also satisfy the needs of.
output all the result.
e.g
input 6
the result like this:
1,2,3
1,5
2,4
How to do what should?
thx.

For your second, it doesn’t really make any sense. You want the list of all the numbers less than, say, 100 that add up to 100? 99+1, 98+2, 97+3, 97+1+2 … 50+1+2+3+4+5+6+7+8+9+… 50+1+49 … 50+10+40 …

I would if I change the conditions. let sequence to meet small to large.Not a continuous sequence also satisfy the needs of.
output all the result.
e.g
input 6
the result like this:
1,2,3
1,5
2,4
How to do what should?
thx.

If you want all possible sums to reach X of positive integers, you’re looking at an entirely different function… and will have a lot more output. I dont know offhand the math on the number of combinations… but for example, X will have floor(X/2) possible 2-number combinations for it… (There’s a formula somewhere that i’m trying to flesh out, but it’s eluding me at the moment)