class FloydTriangle {
public static void main(String args[]) {
int rows = 7;
int n = 1;
int c;
int d;
System.out.println("Floyd's triangle:");
for ( c = 1 ; c <= rows ; c++ ) {
for ( d = 1 ; d <= c ; d++ ) {
System.out.print(n + " ");
n++;
}
System.out.println();
}
}
}
Output:
$ java FloydTriangle Floyd's triangle: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28