+ 2

Guys, help me with a Java Program!!?

Write a program to print the series-- 1+2+3+4=10 5+6+7+8=26 9+10+11+12=42 13+14+15+16=58 17+18+19+20=74

5th Oct 2017, 3:31 PM
Aaron Stone
Aaron Stone - avatar
6 Answers
+ 14
This is not a challenge, but i have nothing to do: https://code.sololearn.com/W7SDbMc5iPPF/?ref=app
5th Oct 2017, 5:02 PM
Maz
Maz - avatar
+ 5
class series{ public static void main(String[ ]args){ int sum=0,i; for(i=1;i<5;i++) { sum=sum+i; } System.out.println(sum); sum=0; for(i=5;i<9;i++) { sum=sum+i; } System.out.println(sum); sum=0; for(i=9;i<13;i++) { sum=sum+i; } System.out.println(sum); sum=0; for(i=13;i<17;i++) { sum=sum+i; } System.out.println(sum); sum=0; for(i=17;i<21;i++) { sum=sum+i; } System.out.println(sum); } }
5th Oct 2017, 4:38 PM
zaid
zaid - avatar
+ 4
ur vlcm
5th Oct 2017, 5:00 PM
zaid
zaid - avatar
+ 1
great..kind of solution I was looking for. very easy with lesser variables. thnks.
5th Oct 2017, 4:51 PM
Aaron Stone
Aaron Stone - avatar
0
thanks again Gordie...:) Got it
11th Oct 2017, 9:12 AM
Aaron Stone
Aaron Stone - avatar