Okay so the description says: for a given number write all sums of consecutive numbers. for example, if i enter 9; the program needs to say: 4+5, or 4,5 or whatever. if i put in 15 it needs to say 1+2+3+4+5 AND 7+8.
i tried doing it with like 10 if statements but that's not allowed. is there a program that can do this for any entered number?
i mean i get the first part of it. assuming n is the number the first for would be for(int=1;i<=n/2;i++) and from that i can only do 2 consecutive numbers. i'm just trying to get a part of the code that does i+(i+1)+(i+2)+...(i+n/2)
that's the problem, i can't put my finger on the second loop. im not sure where it exactly starts and where it ends. im guessing it starts at j=i, but beyond that im clueless.
Try having a variable outside the loop which you can aggregate the sum in until you've either determined that it adds up to the input number or you've overshot, and proved that that i doesn't work as a starting point.