Computer Science, asked by khanfatima70071, 1 month ago

write a program to obtain sum of 1+2+4+7+11+16 in java using loop

Answers

Answered by ajb7899
0

Answer:

int sum= 0;

int k=1;

for(int i=1; i<=6;i++)

{

sum = sum+k;

k = k +i;

}

System.out.println(k);

Similar questions