logoStarPatterns
Back to Patterns

Inverted Hollow Pyramid

Pattern Result

*********
* *
* *
* *
*

Code Implementation

Explanation

The Inverted Hollow Pyramid pattern creates an upside-down triangle where only the border is visible. The pattern consists of three parts: the first row (a horizontal line of stars), the middle rows (two stars with spaces in between), and the last row (a single star in the middle). The first row is completely filled with stars to form the base of the inverted pyramid. For the middle rows, stars are placed only at specific positions to create the hollow effect, with the distance between the two stars decreasing as the row number increases. The last row contains a single star in the middle to form the tip of the inverted pyramid. The outer loops handle the three parts separately, while the inner loops handle the spaces and stars in each row.