Inverted Number Triangle

Given a positive integer n, return an inverted number triangle with n rows. The first row contains the digits 1 through n without spaces. Each later row…

Given a positive integer n, return an inverted number triangle with n rows. The first row contains the digits 1 through n without spaces. Each later row removes the final digit until the last row is 1. Join adjacent rows with one newline character and do not add spaces or a trailing newline.

- 1 ≤ n ≤ 9 - n is always a positive integer. - The upper bound keeps every emitted value to one digit.

Example 1: input n = 5; output 12345 1234 123 12 1. Every row is a prefix of the first row and loses its final digit.

Example 2: input n = 1; output 1. The smallest inverted triangle contains only the digit 1.

Category: Pattern Programs. Topic: pattern-programs. Difficulty: Easy. Patterns: math.