logoStarPatterns
Back to Patterns

Reverse Number Triangle Pattern

Pattern Result

1 2 3 4
1 2 3
1 2
1

Code Implementation

Explanation

The Reverse Number Triangle Pattern creates an inverted triangle where each row contains numbers from 1 to the row's maximum value. 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. The inner loop runs from 1 to the current row number, adding the current column number to the row string.