0-Centered Descending Mirror Number Pattern in C#

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
12345678909876543211
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();
}
}
}
}12 people found this page helpful
