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.

  1. Use nested loops:
    • Outer loop (i) for the row number (1 up to rows).
    • Inner loop (j) to print i numbers in that row.
  2. Track a single counter that increases with every number printed.
  3. Print each row's numbers on a single line with spaces.

01EXAMPLE 1

Inputrows = 3
Output1 2 3 4 5 6

Explanation: Three rows of Floyd logic.

Constraints

  • Correct spacing between numbers.
  • New line for each row.
MathLoops
JavaScript
Loading...
3 Hidden

Input Arguments

rows3

Expected Output

1
2 3
4 5 6

Click RUN to test your solution