Descending Left-Growing Number Pattern in C#

Beginner
⏱️ 5 min read
📚 Updated: Aug 2025
🎯 2 Code Examples
Nested Loops

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:

Output
5
54
543
5432
54321
1

Complete C# Program

Outer loop decreases the stop value; inner loop prints from rows down to i.

C#
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

1

Set the size

int rows = 5; decides the maximum digit and the pattern height.

Setup
2

Outer loop (choose the stop digit)

for (i = rows; i >= 1; i--) moves the stop point from 5 down to 1.

Row control
3

Inner loop (print rows..i)

for (j = rows; j >= i; j--) prints numbers in descending order starting from rows.

Descending print
4

New line

Console.WriteLine() ends the current row.

Line break
=

Left-growing descending pattern

Total printed digits are triangular: 1+2+…+n = n(n+1)/2, so time complexity is O(n²).

2

Variation — User Input Version

Read the row count at runtime:

C#
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.TryParse before converting
  • Add spaces with Console.Write(j + " ") for readability
  • Flip the inner loop to print i..rows for an ascending version (see Program 6)
  • Right-align by printing leading spaces before each row

Avoid

  • Forgetting Console.WriteLine() after each row
  • Using Convert.ToInt32 without handling invalid input
  • Incrementing j (this pattern needs a countdown)

Key Takeaways

1

The inner loop always starts at rows, so each line begins with the same digit.

2

The outer loop changes the stopping point, so each next row prints one extra digit.

3

Total digits printed are triangular: n(n+1)/2.

4

This is a clean practice pattern for reverse counting in nested loops.

❓ Frequently Asked Questions

Because the inner loop always begins at j = rows. Only the stopping value changes.
Change the inner loop to count up and start from i: for (j = i; j <= rows; j++) (see Program 2).
O(n²) for n rows since total prints are n(n+1)/2.

Explore More C# Number Patterns!

Keep practicing reverse counting and boundary changes to get comfortable with nested loops.

All Number Patterns →
Did you know?

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.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful