logoStarPatterns
Back to Patterns

Right Pascal's Triangle

Pattern Result

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

Code Implementation

Explanation

The Right Pascal's Triangle pattern combines a left-aligned half pyramid with its inverted version to create a pattern that resembles a right-angled triangle followed by its mirror image. The pattern consists of two parts: the increasing part where the number of stars increases from 1 to n, and the decreasing part where the number of stars decreases from n-1 back to 1. The algorithm uses nested loops to create the pattern: separate outer loops handle the increasing and decreasing parts, while the inner loops add the stars for each row.