Back to Patterns
Mirror Image Triangle Pattern
Pattern Result
1 2 3 4 3 2 11 2 3 2 11 2 11
Code Implementation
Explanation
The Mirror Image Triangle Pattern creates a triangle where each row contains numbers that increase from 1 to the row's maximum value and then decrease back to 1, forming a mirror image. The pattern starts with the longest row at the top and decreases in length with each subsequent row. The outer loop iterates from n down to 1, representing each row. For each row, we use two inner loops: the first loop adds numbers in increasing order from 1 to i, and the second loop adds numbers in decreasing order from i-1 down to 1.