Star Pyramid
Submit solution
Points:
10
Time limit:
1.0s
Memory limit:
98M
Authors:
Problem type
Allowed languages
Java 19
Description
Given a positive integer n, print a centered pyramid of * with exactly n rows.
The top row has 1 star centered; each next row increases the star count by 2.
Notes: Spaces on the left of each line are part of the output and must be preserved.
Sample Input / Output
| Sample | Input | Output |
|---|---|---|
| 1 | 1 |
* |
| 2 | 2 |
**** |
| 3 | 5 |
************************* |
Comments