Shape Rule
× 11 each row
Start res = 1; each iteration prints res, then res = res * 11.

The powers-of-11 pattern prints 1, 11, 121, 1331, 14641 — each line is the previous value multiplied by 11. This tutorial covers the single-loop logic, overflow-safe BigInteger variant, live preview, worked Java examples, edge cases, and complexity.
× 11 each row
Start res = 1; each iteration prints res, then res = res * 11.
i = 1..rows
for (i = 1; i <= rows; i++) — one line printed per iteration.
BigInteger
Use long for small demos; switch to BigInteger when rows grow — Example 2.
Early rows
First few lines match Pascal’s triangle rows written without spaces.
3–12 rows
Pick a row count and draw the powers of 11 pattern instantly in the browser.
Complexity
One loop iteration per row — linear time; extra memory stays O(1).
A powers-of-11 number pattern prints 1, then 11, then 121, up to 14641 for five rows. Each line equals the previous value times 11.
In Java you initialize long res = 1, loop rows times, call println(res), then update with res = res * 11.
It is a compact single-loop exercise that also connects to Pascal’s triangle and overflow awareness.
res = 1 produces the first line.
res *= 11 after each print.
No nested loops — one iteration, one line.
Follow Program 47 concentric diamond; continue to Program 49 multiplication triangle.
In short: res = 1, loop rows times, println(res), then res *= 11.
Given rows = 5, print five lines: 1, 11, 121, 1331, 14641.
// rows = 5 (conceptual output)
// 1
// 11
// 121
// 1331
// 14641 | Item | Type | Description |
|---|---|---|
rows | int | How many lines to print (typically ≥ 1). |
res | long / BigInteger | Running value — starts at 1, multiplied by 11 each step. |
| Printed output | text | One number per line — rows total lines. |
res = 1
for i from 1 to rows:
print res
res = res * 11 | Approach | Idea | Best for |
|---|---|---|
| long multiply | res = res * 11 after each print | Small row counts (≤ ~9 safely) |
| BigInteger + Scanner | res.multiply(11) | Large row counts without overflow |
| Single-line output | print(res + " ") | Compact one-row display — Example 3 |
| Goal | Pattern |
|---|---|
| Initialize | long res = 1; |
| Loop rows | for (i = 1; i <= rows; i++) |
| Print line | System.out.println(res); |
| Update | res = res * 11; |
| BigInteger update | res = res.multiply(BigInteger.valueOf(11)); |
| Program 47 contrast | Concentric diamond uses nested loops; this pattern uses one loop and multiply-by-11 |
Three phases of each loop iteration — print the current value, then prepare the next line.
res = 1First line is always 1 before any multiplication.
println(res)Output the current value on its own line.
res *= 11Multiply by 11 to get the next row’s value.
trace i=3Dry-run iteration 3: res=121 → prints 121, then res=1331.
Reach for this pattern when teaching single-loop series, overflow awareness, and Pascal’s-triangle connections.
Classic follow-up after concentric diamonds and single-loop series patterns.
Introduce long vs BigInteger when values grow quickly.
Combine loops with Scanner for a flexible row count.
Compare with Program 47 (concentric diamond), then continue to Program 49 (multiplication triangle).
This is a console teaching pattern — not how you build modern app screens.
Key benefit: one small program that locks in loop variables, running totals, and O(n) thinking.
Choose a row count and draw the powers of 11 pattern in the browser.
Three complete Java programs — fixed rows with long, BigInteger + Scanner, and a single-line output variant. Click View Output to reveal sample console results.
Print five lines with a single loop and multiply-by-11 updates.
rows = 5 (long)Hard-coded size — print res, then multiply by 11 each iteration.
public class PowersOf11Pattern {
public static void main(String[] args) {
int rows = 5;
long res = 1;
for (int i = 1; i <= rows; i++) {
System.out.println(res);
res = res * 11;
}
}
} Iteration 1 prints 1, then res becomes 11. Iteration 2 prints 11, then res becomes 121 — and so on.
Use BigInteger so larger row counts do not overflow.
Read rows with Scanner and multiply with BigInteger.
import java.math.BigInteger;
import java.util.Scanner;
public class PowersOf11PatternInput {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of rows: ");
int rows = sc.nextInt();
BigInteger res = BigInteger.ONE;
BigInteger eleven = BigInteger.valueOf(11);
for (int i = 1; i <= rows; i++) {
System.out.println(res);
res = res.multiply(eleven);
}
sc.close();
}
} Same loop structure as Example 1; BigInteger grows without the overflow limits of long.
Print all values on one line separated by spaces.
Use print with a trailing space, then one final println.
public class PowersOf11PatternInline {
public static void main(String[] args) {
int rows = 5;
long res = 1;
for (int i = 1; i <= rows; i++) {
System.out.print(res + " ");
res = res * 11;
}
System.out.println();
}
} Same multiply-by-11 logic; only the output format changes — one horizontal line instead of five vertical lines.
System.out is built in; use Scanner when reading input. Set rows and initialize res = 1.
for (i = 1; i <= rows; i++) — one iteration per output line.
println(res) then res = res * 11 prepares the next line.
After 5 iterations: 1, 11, 121, 1331, 14641 — linear O(n) work.
Total lines printed = rows — O(n) time, O(1) extra memory.
i = 3Trace the third loop iteration to see print-then-multiply in action.
| Step | res before | Action |
|---|---|---|
| i = 1 | 1 | print 1 → res = 11 |
| i = 2 | 11 | print 11 → res = 121 |
| i = 3 | 121 | print 121 → res = 1331 |
Line 3 output: 121 — five rows produce five values ending at 14641.
Where this tiny pattern (and its loop structure) shows up beyond the homework prompt.
Classic intro to accumulator variables updated each iteration.
Example: use BigInteger for large row counts — see Example 2.
Early rows match Pascal without spaces — great math connection.
Example: compare row 5 (14641) with Pascal row coefficients.
Practice println vs print for multi-line vs single-line output.
Example: put System.out.print(res + " ") for one-line output — Example 3.
Watch int and long limits as values grow by 11 each step.
Example: print 10+ rows and observe when long wraps.
One loop iteration per row makes O(n) concrete for beginners.
Example: count lines for rows=5 → five values from 1 up to 14641.
Pair the pattern with Scanner and positive-row checks.
Example: reject rows <= 0 and re-prompt.
Pro Tip: when an interviewer asks for patterns, explain the print-then-update order first — then write the loop. The story matters as much as the code.
Why this pattern earns a permanent spot in beginner Java courses.
Wrong update order (multiply before print) skips the first line 1.
Only loops and console output — no arrays or math libraries.
Change rows, switch to BigInteger, or print on one line with spaces.
Streaming output needs no storage beyond loop counters.
Pro Tip: learn the fixed-rows loop first; then try BigInteger input and the single-line variant in Example 3.
Small habits that keep number-pattern code clean.
Use rows for the loop bound and res for the running value.
ScannerAvoid crashes when the user types letters instead of a number.
Always println(res) before res *= 11 so the first line is 1.
Use long for demos; switch to BigInteger when rows grow.
Trace rows = 3 on paper before coding larger demos.
Pro Tip: if the first line is missing or wrong, check whether you multiply before printing.
Mistakes that commonly break powers of 11 number patterns.
Updating res first skips the initial value 1 on line one.
→ Print res, then multiply: res = res * 11.
int overflows after a few multiplications by 11 — values become negative or wrong.
→ Use long for small demos or BigInteger for larger row counts.
Wrong initial value shifts the entire sequence.
→ Initialize res = 1 (or BigInteger.ONE).
Using only print may leave the cursor on the same line as the last value.
→ Add System.out.println() after the loop — Example 3.
Letters or empty input throw InputMismatchException.
→ Use sc.hasNextInt() before sc.nextInt().
Using literal 5 in loop bounds instead of variable rows breaks dynamic input.
→ Use one rows variable for the loop bound.
Check these inputs before calling the solution done.
Output is one line: 1.
Loop never runs — print nothing or show a message.
rows < 0Treat as invalid; re-prompt instead of silent empty output.
long overflows around row 10; use BigInteger for more lines.
Unchecked Scanner leaves rows unset — call sc.hasNextInt() first.
Use print(res + " ") for one horizontal line — see Example 3.
Try these variations to lock in the pattern.
rows = 3, 6, or 8long overflowsrows (e.g. 5 lines for rows=5).print stays on the line; println advances — mix them carefully.rows > 0 for interactive programs; rows = 1 prints one value.1.Quick Takeaway: set res=1, loop rows times, println(res), then res *= 11.
| Program | Time | Extra space |
|---|---|---|
| Fixed rows (Example 1) | O(n) | O(1) |
| BigInteger + Scanner (Example 2) | O(n) loop; multiply cost grows with digits | O(1) |
| Single-line output (Example 3) | O(n) | O(1) |
The powers of 11 pattern combines a single loop with repeated multiplication — a natural step after concentric number diamonds. Master the fixed-rows version first, then try BigInteger input and the single-line variant in Example 3.
Practice the three examples above, then continue to Program 49 for the multiplication number triangle pattern.
Print before update — keep res = 1 as the starting value.
res=1, print, and res*=11 before codingprintln(res) then res *= 11 each iterationrows ≥ 1 for interactive programsScanner return value before using rows1)int for many rows (overflows quickly)rowsrows = 1 edge casePrint the pattern the beginner-friendly way.
Each row prints res
res = 1
Coderes *= 11
Logicn iterations
O(n)
AnalysisStart with res = 1, print it, then multiply by 11 each row. The first five lines are 1, 11, 121, 1331, 14641 — early rows resemble Pascal’s triangle without spaces.
Move on to the multiplication number triangle pattern in the Java number-pattern series.
12 people found this page helpful