Practice/fresherPyramid Pattern
⏱ 00:00
Best: 0/100
Nested Loops & SpacingTarget Time: 10 mins

Pyramid Pattern

Given an integer N, print a centered symmetric pyramid of stars with N rows. Each row i has leading spaces to center it, and contains (2*i - 1) stars.

Input Format
A single integer N.
Output Format
Print N centered rows of stars.
Constraints:1 <= N <= 15
Concepts Required:
Leading spaces calculationOdd number sequence 2*i - 1Symmetric formatting
Expected Pattern PreviewASCII Monospace
    *
   ***
  *****
 *******
*********

Notice how character spacing and row counts scale systematically based on the input N.

Concrete Examples

Example 1
Input:
5
Output:
    *
   ***
  *****
 *******
*********

Explanation: Row 1 has 4 spaces and 1 star. Row 5 has 0 spaces and 9 stars.

← Back to All Challenges