I wan't to add integers 1 to 30. How can I do that in java. I tried using for and while loop but failed to add the integers. I only get 1,2,3 etc.But I wan't to add 1+2+3 etc. It has to be 0 + 1 =1 1 + 2 =3 3 + 3 =6 6 + 4 =10 10 + 5 =15 15 + 6 =21 and so on upto 30. Please help me or tell me the other way I can do it in Java. Correct me if I am wrong.
YesYourTheOne .... please read here about our naming policy ... your name does not comply please register again with a valid name. Also I deleted your prvious post because it was rude and irrelevent to the discussion. Please keep your posts friendly, helpful and above all .. on topic!
Pounding at a thick stone wall won't move it, sometimes, you need to step back to see the way around.
Thanks Peter Tran, I tried the coding. It's exactly what I was looking for but was not able to do the way you did it coz I was not using your first println statement: System.out.println(sum+"+"+i+"="); Thanks again. [This message has been edited by Swati Samudra (edited January 18, 2001).]