#K76342. Mirrored Triangle Pattern
Mirrored Triangle Pattern
Mirrored Triangle Pattern
This problem requires you to generate a mirrored right triangle pattern using the hashtag character (#
). Given an integer n as input, you are to print n lines. The i-th line (1-indexed) should consist of (n-i)
spaces followed by i
hashtags.
For example, if n = 3, then the output should be:
# ## ###
This pattern is formally described by the formula below for each line i: \[ line_i = \text{`` ''}^{(n-i)} + \text{``#''}^{(i)} \]
Note: There should be no extra spaces at the end of each line, and there should be no trailing newline after the last line.
inputFormat
The input is read from stdin and consists of a single integer n on one line (1 ≤ n ≤ 100), representing the number of levels in the mirrored triangle pattern.
outputFormat
The output is printed to stdout and consists of n lines. The i-th line should contain (n-i)
space characters followed by i
hashtag characters (#
), with no trailing space or newline after the final line.
1
#