Patternia LogoPatternia Logo

Right-Angled Triangle

Pattern Display

*
* *
* * *
* * * *
* * * * *

Implementation

n = 5
for i in range(1, n + 1):  # Outer loop for rows
    for j in range(i):  # Inner loop for stars
        print("*", end=" ")  
    print()  # Moves to the next line

Steps

Identify Rows and Columns

  • The number of rows (n) determines the height of the pattern.
  • Each row i contains i stars (*).

Looping Strategy

  • Use an outer loop for rows (i from 1 to n).
  • Use an inner loop for columns (print i stars in the ith row).

Printing Output

  • Print stars on the same line using end=" " to maintain spacing.
  • After finishing one row, move to the next line using print().

Pattern Output

*
* *
* * *
* * * *
* * * * *