83.7k views
0 votes
Loop 1: sum up all of the values from 1 to 10, outputting the sum as you go. For instance, it will output 1, 3 (1+2), 6 (1+2+3), 10 (1+2+3+4), etc (on separate lines).

User Boss Nass
by
4.1k points

1 Answer

0 votes

Answer:

Here is a solution in Java:

public class Main {

public static void main(String[] args) {

int sum = 0;

for (int i = 1; i <= 10; i++) {

sum += i;

System.out.println(sum);

}

}

}

User Victor Savu
by
3.9k points