Floyd's Pyramid

MediumAcc. 91.4%
+25 XP 10

Aligned Ascension

Like Floyd's triangle, but mirrored or centered to form a symmetrical pyramid.

The Assignment

Your function receives a parameter rows.

  1. Outer loop for row index (i).
  2. First inner loop: print leading spaces to center the numbers.
  3. Second inner loop: print the numbers for that row with a space between them.
  4. Correct alignment: The last row has the most numbers.

01EXAMPLE 1

Inputrows = 2
Output 1 2 3

Explanation: Centered two rows.

Constraints

  • Each row must start with computed spaces.
  • Numbers are consecutive.
MathLoops
JavaScript
Loading...
2 Hidden

Input Arguments

rows2

Expected Output

 1
2 3

Click RUN to test your solution