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.
- Outer loop for row index (
i). - First inner loop: print leading spaces to center the numbers.
- Second inner loop: print the numbers for that row with a space between them.
- Correct alignment: The last row has the most numbers.
01EXAMPLE 1
Input
rows = 2Output
1
2 3Explanation: Centered two rows.
Constraints
- Each row must start with computed spaces.
- Numbers are consecutive.
MathLoops
JavaScriptSystem handles I/O — write your function only
Loading...
2 Hidden
Input Arguments
rows2
Expected Output
1 2 3
Click RUN to test your solution