Print 1, 11, 121, 1331… Pattern in C#

What You’ll Learn
How to print the sequence-like number pattern 1, 11, 121, 1331, 14641 in C#.
You’ll use a simple loop and update a running value on each iteration (multiplying by 11 for the first few rows).
⭐ Pattern Output
For n = 5, the pattern looks like this:
1
11
121
1331
14641Complete C# Program
Start with res = 1 and multiply by 11 each row to generate the next value.
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
int i, res = 1;
for (i = 1; i <= 5; i++)
{
if (i == 1)
res = i;
else
res = res * 11;
Console.Write(res);
Console.WriteLine();
}
}
}
}🧠 How It Works
Initialize the result
int res = 1; holds the current value that will be printed on each row.
Loop through rows
for (i = 1; i <= 5; i++) runs once per printed line.
Update the value
For the first row, set res = i (prints 1). For later rows, update with res = res * 11.
Print and move to next line
Console.Write(res) prints the current number and Console.WriteLine() moves to the next row.
Growing number pattern
You print exactly one value per row, so the time complexity is O(n) for n rows.
Variation — User Input Rows
Let the user decide how many lines to print. (For larger values, prefer BigInteger.)
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
int n;
Console.Write("Enter number of rows: ");
if (!int.TryParse(Console.ReadLine(), out n) || n <= 0)
{
Console.WriteLine("Please enter a positive integer.");
return;
}
int res = 1;
for (int i = 1; i <= n; i++)
{
if (i == 1)
res = 1;
else
res = res * 11;
Console.WriteLine(res);
}
}
}
}💡 Tips for Enhancement
Try These
- Print each row with padding (e.g.,
Console.WriteLine(res.ToString().PadLeft(...))) for a cleaner look - Use
System.Numerics.BigIntegerif you want many rows without overflow - Swap the multiplier (e.g., 9, 12) to explore different growth patterns
- Generate the same values using binomial coefficients (for small rows)
Avoid
- Printing many rows with
int(you will overflow quickly) - Skipping input validation when reading
nfrom the user - Assuming the digits always match Pascal’s triangle (carries break the pattern)
Key Takeaways
You can generate the next row by multiplying the previous value by 11 (for the first few rows).
This program prints one value per row, so it runs in O(n) time.
Numbers grow quickly—use BigInteger when printing many rows.
For small rows, these values relate to binomial coefficients; carries make later rows differ.
❓ Frequently Asked Questions
1, the program updates the value with res = res * 11 and prints it on the next line.n from input. For many rows, use BigInteger to avoid overflow.Explore More C# Number Patterns!
Mix sequences, symmetry, and loops to level up your pattern-printing skills.
Powers of 11 display binomial coefficients in their digits only for the first few rows. Once digit carries occur, the visual match breaks—but the loop-based approach still works for generating this specific pattern for small n.
12 people found this page helpful
