I’ve now googled around and tried various methods myself without any success.
So to the problem,
I’ve got this loop, I type in a number “n” ex. 10. Then the program counts from 1 to 10.
This is the loop I’m using.
n = Keyboard.readInt();
for(int e = 1; e <=n; e++)
System.out.println(e);
That works fine, but now I want to calculate the numbers that has been shown in loop so..It would be 1+2+3+4+5+6+7+8+9+10 (If ‘n’ was chosen as number 10) and it should give the calculation of that so it would say 1+2+3+4+5+6+7+8+9+10 = 55.
Would be great if anyone here could help me.
Thanks in advance,
Michael.
Do it like that: