The Floyd Triangle
EasyAcc. 95.9%
+15 XP 5
Consecutive Growth
Floyd's triangle is a right-angled triangular array of natural numbers, used in computer science education. 1 2 3 4 5 6 7 8 9 10
The Assignment
Your function receives a parameter rows.
- Use nested loops:
- Outer loop (
i) for the row number (1 up torows). - Inner loop (
j) to printinumbers in that row.
- Outer loop (
- Track a single
counterthat increases with every number printed. - Print each row's numbers on a single line with spaces.
01EXAMPLE 1
Input
rows = 3Output
1
2 3
4 5 6Explanation: Three rows of Floyd logic.
Constraints
- Correct spacing between numbers.
- New line for each row.
MathLoops
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
rows3
Expected Output
1 2 3 4 5 6
Click RUN to test your solution