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

Question

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

in progress 0
Camila 2 years 2021-06-24T13:49:48+00:00 1 Answers 0 views 0

Answers ( )

    0
    2021-06-24T13:51:35+00:00

    Answer:

    int sum= 0;

    int k=1;

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

    {

    sum = sum+k;

    k = k +i;

    }

    System.out.println(k);

Leave an answer

Browse

9:3-3+1x3-4:2 = ? ( )