Shape Rule
Multiply by 11
Each row is the previous value times 11 — starting from 1.

Program 48 prints the powers-of-11 sequence: 1, 11, 121, 1331, 14641 — a natural step after Program 47’s 2D concentric diamond. This tutorial covers a simple loop with running state (res *= 11), a live preview, worked C# examples, edge cases, and complexity.
Multiply by 11
Each row is the previous value times 11 — starting from 1.
i = 1..n
for (i = 1; i <= n; i++) prints one value per row.
res variable
res holds the current number — update with res *= 11 after each print.
Early rows only
First few values mirror binomial coefficients until base-10 carries break the pattern.
n = 3..8
Pick row count and generate the sequence in the browser.
Complexity
One value per row — n prints total; extra memory stays O(1).
A powers-of-11 sequence prints one growing number per row: start at 1, then multiply by 11 for each next line. With n = 5, the output is 1, 11, 121, 1331, 14641.
In C# a single loop runs i = 1..n, a variable res holds the current value, and you print then update with res *= 11.
It teaches running state in a loop — a simpler pattern after Program 47’s nested diamond grids.
res = 1 first row.
res *= 11 each step.
Program 47 is a 2D diamond; Program 48 is a 1D sequence.
Follow Program 47; continue to Program 49 next.
In short: loop i = 1..n, print res, update res *= 11, then WriteLine().
Given row count n = 5, print the powers-of-11 sequence — one growing number per line, starting at 1 and multiplying by 11 each step.
// n = 5
//1
//11
//121
//1331
//14641 | Item | Type | Description |
|---|---|---|
n | int | How many rows (values) to print. |
res | int | Running value — starts at 1, updated with res *= 11. |
i | int | Loop counter from 1 to n. |
| Printed output | text | One number per line — 1, 11, 121, … |
res = 1
for i from 1 to n:
print res
res = res * 11 | Approach | Idea | Best for |
|---|---|---|
| if/else on first row | if (i == 1) res = i; else res *= 11 | Matching classic textbook code |
| Print then multiply | WriteLine(res); res *= 11; | Cleaner loop body — see Example 3 |
| User-input n | int.TryParse(...) | Flexible row count |
BigInteger | Arbitrary-precision multiply | Many rows without overflow |
| Goal | Pattern |
|---|---|
| Initialize | int res = 1; |
| Loop rows | for (i = 1; i <= n; i++) |
| Print value | Console.WriteLine(res); |
| Update state | res *= 11; (or res = res * 11;) |
| Classic first-row check | if (i == 1) res = i; else res *= 11; |
| Cleaner variant | Print first, multiply after — no if needed |
| Program 47 contrast | Program 47 is a 2D diamond; Program 48 is a 1D sequence |
Same sequence — three ways to structure the loop and set row count.
if (i == 1)Special-case first row before multiply
TryParse(n)Read row count from console
print; res *= 11No if/else — print then update
BigIntegerAvoid int overflow past ~row 10
* 11Each step grows by one power of 11
Reach for this pattern when teaching running state, sequence growth, and single-loop output.
Natural follow-up after Program 47’s nested diamond — simpler 1D sequence with one loop.
res carries value from row to row — core loop-state pattern.
Early rows mirror binomial coefficients until base-10 carries break the match.
Compare Program 47 (2D diamond) and Program 49 (next in series) next.
This is a console teaching pattern — not how you build modern app screens.
Key benefit: one small program that locks in loop state, multiply-update logic, and O(n) thinking.
Choose row count n between 3 and 8 and generate the powers-of-11 sequence in the browser.
Three complete C# programs — fixed rows, user input, and a cleaner print-then-multiply loop. Click View Output to reveal sample console results.
Print five rows of the powers-of-11 sequence with the classic if/else first-row check.
n = 5Hard-coded row count — matches the textbook version with if (i == 1).
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();
}
}
}
} Row 1 sets res = 1 and prints it. Each later row multiplies res by 11 before printing — producing 11, 121, 1331, and 14641.
Read row count n from the console with safe parsing.
Read n from the console with int.TryParse — reject invalid input gracefully.
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);
}
}
}
} Same multiply logic as Example 1; only the source of n changes. For large n, switch to BigInteger to avoid overflow.
Print first, then multiply — no special-case if needed.
Print res at the start of each iteration, then update with res *= 11.
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;
}
}
}
} Because res starts at 1, the first print is correct without an if. Multiply happens after printing, so the next iteration gets the updated value.
int res = 1; holds the current value to print on each row.
for (i = 1; i <= n; i++) runs once per printed line.
First row: res = i. Later rows: res = res * 11 — or print first, then res *= 11.
Console.WriteLine(res) outputs one number per row.
One value per row — O(n) time, O(1) extra memory.
n = 5Trace each iteration — what res holds before and after the multiply step (print-then-multiply variant).
i | Prints | After res *= 11 |
|---|---|---|
1 | 1 | 11 |
2 | 11 | 121 |
3 | 121 | 1331 |
4 | 1331 | 14641 |
5 | 14641 | 161051 (next row if continued) |
Row 6 would print 161051 — the first value where digit carries break the Pascal-triangle visual match, but the multiply loop still works correctly.
Where this tiny pattern (and its loop structure) shows up beyond the homework prompt.
Classic intro to carrying a value from iteration to iteration.
Example: trace the walkthrough table for n = 5.
Follow Program 47’s diamond; continue to Program 49 next.
Example: compare 2D vs 1D pattern complexity.
Practice Write vs WriteLine with one value per row.
Example: use WriteLine(res) instead of Write + WriteLine().
Early rows mirror binomial coefficients — great math tie-in.
Example: row 5 prints 14641 = coefficients of (a+b)&sup4;.
n rows, one print each — O(n) is easy to count.
Example: 5 rows = 5 prints total.
Values grow fast — intro to BigInteger for larger n.
Example: row 10 exceeds int max — use BigInteger.
Pro Tip: when an interviewer asks for patterns, explain the state variable first — then write the loop. The story matters as much as the code.
Why this pattern earns a permanent spot in beginner C# courses.
No nested loops — easier after Program 47’s diamond grid.
Only one loop, one variable, and console output — no arrays needed.
Change n, swap to print-then-multiply, or use BigInteger for many rows.
Streaming output needs no storage beyond res and loop counter.
Pro Tip: trace the walkthrough table on paper — watch how res grows by one power of 11 each row.
Small habits that keep number-pattern code clean.
Start with 1 so the first printed value is correct.
Avoid crashes when the user types letters instead of a number.
Cleaner than if (i == 1) — see Example 3.
int overflows around row 10 — switch to arbitrary precision.
Trace three rows on paper before coding the full n = 5 demo.
Pro Tip: if values look wrong after row 1, check whether you multiply before or after printing.
Mistakes that commonly break powers-of-11 sequence patterns.
First row prints 11 instead of 1 if you multiply before printing.
→ Print first, then res *= 11 — or use the if (i == 1) check.
Every row prints 1 if you never multiply.
→ Add res = res * 11 or res *= 11 each iteration.
Values exceed int.MaxValue around row 10.
→ Use System.Numerics.BigInteger for larger row counts.
Using 10 or 12 instead of 11 produces a different sequence.
→ Confirm the pattern requires multiply-by-11.
Letters or empty input throw FormatException.
→ Prefer int.TryParse and re-prompt on failure.
Check these inputs before calling the solution done.
Output is just 1 on one line.
Loop never runs — print nothing or show a message.
n < 0Treat as invalid; re-prompt instead of silent empty output.
1, 11, 121, 1331, 14641 — last row before carry breaks Pascal match.
Convert.ToInt32 throws — use TryParse.
Values grow exponentially — use BigInteger past ~row 10.
Try these variations to lock in the pattern.
BigInteger res = 1res carries the current value — update with res *= 11 after each print (or before, with an if-check).Console.WriteLine(res) is cleaner than Write(res) + empty WriteLine().n > 0 for interactive programs; n = 1 prints a single 1.n rows, one print each — total work is O(n) with O(1) extra memory.Quick Takeaway: loop i = 1..n, print res, update res *= 11, then WriteLine().
| Program | Time | Extra space |
|---|---|---|
| Single loop (Examples 1–3) | O(n) | O(1) |
| BigInteger variant | O(n × d) where d = digit count | O(d) for stored value |
The powers-of-11 sequence is a simple follow-up to Program 47: one loop, a running res variable, and multiply-by-11 each row. Master the fixed-n version, then try user input and the cleaner print-then-multiply loop.
Practice the three examples above, then continue to Program 49 for the next pattern in the series.
Print first, multiply after — or use if (i == 1) in the classic variant. Both produce the same first five rows.
res = 1 before the loopres *= 11 for a clean loop bodyint.TryParse for user inputBigInteger for many rowsn > 0 for interactive programsres each iterationint for row counts that cause overflowPrint the pattern the beginner-friendly way.
res *= 11 each row
Definitionres = 1
Codei = 1..n
CodeOne value per line
LogicO(n) time
AnalysisStart with res = 1, print it, then update with res = res * 11 each row. For the first five rows you get 1, 11, 121, 1331, 14641 — one value per line, O(n) time.
Move on to the next pattern in the C# number-pattern series.
12 people found this page helpful