Star Square

Given a positive integer n, print a solid n × n square of stars. Every one of the n rows holds exactly n stars, so the figure is a filled block that is as…

Given a positive integer n, print a solid n × n square of stars. Every one of the n rows holds exactly n stars, so the figure is a filled block that is as wide as it is tall. Do not add trailing spaces to any row. Join all rows with a single newline character and do not add a trailing newline at the end.

- 1 ≤ n ≤ 20 - n is always a positive integer. - The output must contain exactly n rows, each with exactly n stars and no trailing spaces.

Example 1: input n = 3; output *** *** ***. Three rows, each containing three stars. The result is a 3 × 3 filled block.

Example 2: input n = 4; output **** **** **** ****. Every row is identical — four stars — and there are four rows, forming a 4 × 4 square.

Example 3: input n = 1; output *. n = 1 produces a single row with a single star.

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