01: public class MainClass {
02: public static void main(String[] arg) {
03: int limit = 10;
04: int sum = 0;
05:
06: int i = 1;
07: for (; i <= limit;) {
08: sum += i++;
09: }
10: System.out.println(sum);
11: }
12: }
The short formula for such a row is n*(n+1)/2 = 10*11/2 = 110/2 = 55
2018 Nov 30, 5:41:50 PM
Login in to like
Login in to comment