VOOZH about

URL: https://www.geeksforgeeks.org/dsa/right-aligned-number-triangle/

⇱ Right-Aligned Number Triangle - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Right-Aligned Number Triangle

Last Updated : 11 Mar, 2026

Given an integer N, print the pattern shown below.

Examples:

Input: N = 3

Output:

👁 3

Input: N = 6

Output:

👁 1

Using Nested Loops - O(n^2) Time and O(1) Space

  • The pattern forms a right-angled triangle of numbers.
  • In each row, numbers start from 1 and go up to the row number.
  • Use an outer loop to handle the rows from 1 to N.
  • For each row, use an inner loop to print numbers from 1 to the current row index, then move to the next line.

Output
1 
1 2 
1 2 3 
1 2 3 4 
1 2 3 4 5 
Comment
Article Tags: