logoStarPatterns
Back to Patterns

Triangle Star Pattern

Pattern Result

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

Code Implementation

Explanation

The Triangle Star Pattern creates a simple triangle shape using asterisks. Each row contains a number of stars equal to the row number, with spaces between them for better visibility. The outer loop iterates from 1 to n, representing each row. The inner loop runs from 1 to the current row number, adding a star followed by a space to the row string. This pattern is similar to the Left Half Pyramid but with spaces between the stars.