logoStarPatterns
Back to Patterns

Left Half Pyramid

Pattern Result

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

Code Implementation

Explanation

The Left Half Pyramid pattern creates a triangle shape that is aligned to the left side. Each row consists of stars, with the number of stars equal to the row number. The outer loop iterates from 1 to n, representing each row. For each row, we add i stars to create the pyramid shape. This is one of the simplest patterns and serves as a foundation for more complex patterns.