The powers of 11 pattern prints one number per line, starting at 1 and multiplying by 11 each row.
Remember
Rule: res starts at 1; each next row is res * 11
1
11
121
1331
14641 ← n = 5
In C# one loop is enough: keep a running res, print it, then res *= 11. No nested loops required.
Approach
How to Solve It
One loop, one running variable — print, then multiply by 11.
Method
Idea
Best for
Print then multiply
WriteLine(res); res *= 11;
Cleanest loop body
If on first row
if (i == 1) res = 1; else res *= 11;
Matching older textbook code
Pseudocode
Pseudocode
res = 1
for i from 1 to n:
print res
res = res * 11
Cheat sheet
Goal
Pattern
Start value
int res = 1;
Loop rows
for (i = 1; i <= n; i++)
Print line
Console.WriteLine(res);
Next term
res *= 11;
Write vs WriteLine
API
Effect
Use for
Console.WriteLine(res)
Prints the value and ends the line
Preferred — one call per row
Console.Write(res) + WriteLine()
Same result in two calls
Older textbook style (Example 1)
Try it
Live Preview
Change the row count and the powers-of-11 sequence updates instantly.
Whole numbers from 1 to 8 (keeps values within safe integer range). Tap a chip or type a value — the preview redraws as you go.
Live result5 rows · last = 14641
1
11
121
1331
14641
Trace
Worked Walkthrough — n = 5
Trace res before and after each multiply.
Row
Print
Then res *= 11
1
1
11
2
11
121
3
121
1331
4
1331
14641
5
14641
161051 (not printed)
Total prints = n. For larger n, prefer long or BigInteger.
Code
C# Programs
Three complete programs: fixed 5 rows with an if-check, user-input rows, and a clean print-then-multiply loop. Use View Output for sample results.
Example 1 — Fixed n = 5
Textbook style with a special case on the first row.
C#
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();
}
}
}
}
Output
1
11
121
1331
14641
How It Works
1. First row. When i == 1, set res = 1 and print it.
2. Later rows. Multiply the previous res by 11, then print.
3. New line.Write + empty WriteLine ends each row (or use WriteLine(res)).
Example 2 — User Input (rows)
Read n safely and print the first n terms.
C#
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
int n, i, res = 1;
Console.Write("Enter number of rows: ");
if (!int.TryParse(Console.ReadLine(), out n) || n < 1)
{
Console.WriteLine("Please enter a positive whole number.");
return;
}
for (i = 1; i <= n; i++)
{
if (i == 1)
res = 1;
else
res = res * 11;
Console.WriteLine(res);
}
}
}
}
Output (when user enters 4)
Enter number of rows: 4
1
11
121
1331
How It Works
1. Validate n.TryParse rejects non-numeric input; require n >= 1.
2. Same sequence. Only the loop bound changes from the literal 5.
Example 3 — Print Then Multiply
No special-case if — print first, then update.
C#
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
int res = 1;
for (int i = 1; i <= 5; i++)
{
Console.WriteLine(res);
res *= 11;
}
}
}
}
Output
1
11
121
1331
14641
How It Works
1. Print current. Start with res = 1; each iteration prints the current value.
2. Advance.res *= 11 prepares the next row — no if needed.
Edge Cases & Pitfalls
Check these before calling the solution done.
order
Multiply before the first print
If you do res *= 11 before printing when res starts at 1, the first line becomes 11. Print first.
overflow
int overflows around row 10
11^9 exceeds int.MaxValue. Use long or System.Numerics.BigInteger for larger n.
* 10
Multiply by 10 by mistake
You get 1, 10, 100, 1000… Keep the factor 11.
n = 1
Single row
Output is just 1 — valid and useful for testing.
Pascal
Expecting Pascal digits forever
After 14641, carries appear (161051). Digits no longer match binomial coefficients.
Bad input
Convert.ToInt32 throws
Prefer int.TryParse so non-numeric input does not crash the program.
Analysis
Time and Space Complexity
Program
Time
Extra space
Fixed / clean (Examples 1, 3)
O(n)
O(1)
User input (Example 2)
O(n)
O(1)
One multiply and one print per row — linear in the number of rows (unlike nested-loop patterns).
Remember
Key Takeaways
Rule: start at 1; each next line multiplies the previous value by 11.
Clean loop:WriteLine(res); res *= 11; — no if needed.
WriteLine: one value per row — prefer Console.WriteLine(res).
Next step: Program 49 prints a triangular multiplication pattern (i*j).
One line: print the current power-of-11 term, then multiply by 11 for the next row.
Frequently Asked Questions
It starts with res = 1 and multiplies res by 11 for each next row. That produces 1, 11, 121, 1331, 14641 for the first five lines.
Yes — increase the loop limit or read n from input. For many rows, switch to BigInteger because values grow quickly.
11^n shows binomial digits only while there are no base-10 carries. Once carries occur, digits no longer match the triangle.
O(n) for n rows because the program computes and prints one value per row.
Program 47 prints a 2D concentric diamond with nested loops. Program 48 prints a 1D growing sequence with one loop.
Yes — int overflows around row 10. Use long for a few more rows, or BigInteger for larger n.
Yes — print first, then multiply: Console.WriteLine(res); res *= 11; — see Example 3.
161051 — still valid, but digit carries mean it no longer mirrors Pascal row coefficients.
No — a single loop with a running variable is enough for this sequence.
🤔
Did you know?
Start with res = 1, print it, then update with res *= 11 each row. The first five lines are 1, 11, 121, 1331, 14641 — one value per line, O(n) time.