59. Star Pyramid

Acceptance — 0 accepted 0 submissions

Easy
Nested LoopsPatterns
No companies listed
Let's build a proper pyramid like the temple gopuram. Row i has 2i - 1 stars, centred using spaces on the left.

For N = 3, the top row is 2 spaces and 1 star, the middle row is 1 space and 3 stars, and the base is 5 stars. See Example 1 for the exact shape.

Input Format
A single integer N.

Output Format
Print N lines. Line i has N - i spaces followed by 2i - 1 stars. Do not print spaces after the stars.

Constraints
• 1 ≤ N ≤ 40

Example 1

Input
3
Output
  *
 ***
*****

Explanation Row 1: 2 spaces + 1 star. Row 2: 1 space + 3 stars. Row 3: 0 spaces + 5 stars.

Example 2

Input
1
Output
*

Explanation A single star.

Example 3

Input
5
Output
    *
   ***
  *****
 *******
*********

Explanation A 5-row pyramid with 9 stars at the base.

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
* *** *****
No results yet
Run your code to test it against the sample cases.
Problem List