Inverted Star Triangle
Given a positive integer n, return a left-aligned inverted star triangle with n rows. The first row contains n stars, and each later row contains one fewer…
Given a positive integer n, return a left-aligned inverted star triangle with n rows. The first row contains n stars, and each later row contains one fewer star until the final row contains one. Do not add spaces between stars or trailing spaces. Join adjacent rows with one newline character and do not add a trailing newline.
- 1 ≤ n ≤ 10 - n is always a positive integer. - The output contains exactly n rows.
Example 1: input n = 5; output ***** **** *** ** *. The width starts at five and decreases by one on every row.
Example 2: input n = 1; output *. The smallest inverted triangle is one row containing one star.
Category: Pattern Programs. Topic: pattern-programs. Difficulty: Easy. Patterns: math.