Descending Left-Growing Number Pattern in C#

What You’ll Learn
How to print a descending left-growing number pattern in C#. Each row begins with the maximum digit (rows) and grows by adding the next smaller digit to the right: 5, 54, 543, 5432, 54321.
This pattern reinforces nested loops where the inner loop counts down, and its run length grows each row.
⭐ Pattern Output
For rows = 5, the pattern looks like this:
5
54
543
5432
54321Complete C# Program
Outer loop decreases the stop value; inner loop prints from rows down to i.
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
int rows = 5;
int i, j;
for (i = rows; i >= 1; i--)
{
for (j = rows; j >= i; j--)
{
Console.Write(j);
}
Console.WriteLine();
}
}
}
}🧠 How It Works
Set the size
int rows = 5; decides the maximum digit and the pattern height.
Outer loop (choose the stop digit)
for (i = rows; i >= 1; i--) moves the stop point from 5 down to 1.
Inner loop (print rows..i)
for (j = rows; j >= i; j--) prints numbers in descending order starting from rows.
New line
Console.WriteLine() ends the current row.
Left-growing descending pattern
Total printed digits are triangular: 1+2+…+n = n(n+1)/2, so time complexity is O(n²).
Variation — User Input Version
Read the row count at runtime:
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter the number of rows: ");
int rows = Convert.ToInt32(Console.ReadLine());
for (int i = rows; i >= 1; i--)
{
for (int j = rows; j >= i; j--)
{
Console.Write(j);
}
Console.WriteLine();
}
}
}
}💡 Tips for Enhancement
Try These
- Validate input with
int.TryParsebefore converting - Add spaces with
Console.Write(j + " ")for readability - Flip the inner loop to print
i..rowsfor an ascending version (see Program 6) - Right-align by printing leading spaces before each row
Avoid
- Forgetting
Console.WriteLine()after each row - Using
Convert.ToInt32without handling invalid input - Incrementing
j(this pattern needs a countdown)
Key Takeaways
The inner loop always starts at rows, so each line begins with the same digit.
The outer loop changes the stopping point, so each next row prints one extra digit.
Total digits printed are triangular: n(n+1)/2.
This is a clean practice pattern for reverse counting in nested loops.
❓ Frequently Asked Questions
j = rows. Only the stopping value changes.i: for (j = i; j <= rows; j++) (see Program 2).n(n+1)/2.Explore More C# Number Patterns!
Keep practicing reverse counting and boundary changes to get comfortable with nested loops.
Patterns that add one character per row usually print a total of 1+2+…+n = n(n+1)/2 characters—another appearance of triangular numbers.
12 people found this page helpful
