logoStarPatterns
Back to Patterns

Number Triangle Pattern

Pattern Result

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

Code Implementation

Explanation

The Number Triangle Pattern creates a triangle where each row contains the row number repeated as many times as the row number itself. For example, row 3 contains three 3's. The outer loop iterates from 1 to n, representing each row. The inner loop runs from 1 to the current row number, adding that number to the current row string.