0-Centered Descending Mirror Number Pattern in C#

Beginner
⏱️ 7 min read
📚 Updated: Aug 2025
🎯 2 Code Examples
Three Loops

What You’ll Learn

How to print a number pattern that grows into a long mirror sequence with a fixed 0 in the center.

⭐ Pattern Output

The pattern looks like this:

Output
0
909
89098
7890987
678909876
56789098765
4567890987654
345678909876543
23456789098765432
1234567890987654321
1

Complete C# Program

The first loop prints the left ascending part, then we print 0, then the last loop prints the right descending part.

C#
using System;

namespace MyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, j, k;
            for (i = 10; i >= 1; i--)
            {
                for (j = i; j < 10; j++)
                    Console.Write(j);

                Console.Write("0");

                for (k = 9; k >= i; k--)
                    Console.Write(k);

                Console.WriteLine();
            }
        }
    }
}
2

Variation — Custom Max Digit

Choose the maximum digit (like 7 or 9) and generate the same 0-centered mirror:

C#
using System;

namespace MyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Enter max digit (1-9): ");
            int max = Convert.ToInt32(Console.ReadLine());
            if (max < 1) max = 1;
            if (max > 9) max = 9;

            for (int i = max + 1; i >= 1; i--)
            {
                for (int j = i; j <= max; j++)
                    Console.Write(j);

                Console.Write("0");

                for (int k = max; k >= i; k--)
                    Console.Write(k);

                Console.WriteLine();
            }
        }
    }
}

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