Back to Patterns
Right Half Pyramid
Pattern Result
***************
Code Implementation
Explanation
The Right Half Pyramid pattern creates a triangle shape that is aligned to the right side. Each row starts with spaces followed by stars. As the row number increases, the number of spaces decreases and the number of stars increases. The outer loop iterates from 1 to n, representing each row. For each row, we first add (n - i) spaces to create the right alignment, and then add i stars to create the pyramid shape.