Loading...
Loading...
Loading...
Floyd's triangle fills rows with the numbers 1, 2, 3, ... in order. Row 1 has one number, row 2 has two, and so on:
`` 1 2 3 4 5 6 ``
Read n and print the first n rows.
Example
Input
4
Output
1 2 3 4 5 6 7 8 9 10
The numbers 1 to 10 in four rows.
Try the problem first. Open one hint at a time.
The row shape is the same as the star triangle: row i has i items.
Keep a counter outside both loops. Print it and add 1 each time. Do not reset it at a new row.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor