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
Follows the concentric diamond in Program 47; next is the multiplication triangle in Program 49.
Approach
How to Solve It
One loop, one running variable — print, then multiply by 11.
Method
Idea
Best for
Print then multiply
print(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
res = 1
Loop rows
for i in range(1, n + 1):
Print line
print(res)
Next term
res *= 11
Printing Numbers vs Starting a New Line
API
Effect
Use for
print(res)
Prints the value and ends the line
Preferred — one call per row
print(res, end="") + print()
Same result in two calls
Rare here — not needed for this pattern
Same idea as C# WriteLine(res): one value per line. Bare print(res) is enough — no end="" needed.
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 a comfortable 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)
One print and one multiply per row — total work is linear in n.
Code
Python Programs
Three complete programs: fixed 5 rows with an if-check, input() rows, and a clean print-then-multiply loop. Use View Output for sample results.
Example 1 — Fixed n = 5
Textbook-style if on the first row, then multiply for later rows.
Python
res = 0
for i in range(1, 6):
if i == 1:
res = 1
else:
res = res * 11
print(res)
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. Newline. Bare print(res) ends each row automatically.
Example 2 — User Input Rows
Read the row count with input() and build the same sequence.
Python
try:
n = int(input("Enter number of rows: "))
except ValueError:
print("Please enter a positive whole number.")
raise SystemExit(1)
if n < 1:
print("Please enter a positive whole number.")
raise SystemExit(1)
res = 0
for i in range(1, n + 1):
if i == 1:
res = 1
else:
res = res * 11
print(res)
Output (when user enters 4)
Enter number of rows: 4
1
11
121
1331
How It Works
1. Validate n. Catch ValueError; require n >= 1.
2. Same sequence. Only the loop bound changes from the literal 5 to the user value.
3. Safer input tip. Cap demos for readable output:
Safer input tip
if n < 1 or n > 8:
print("Enter a whole number from 1 to 8.")
raise SystemExit(1)
Example 3 — Print Then Multiply
Cleaner loop — no if. Print the current value, then advance.
Python
res = 1
for i in range(5):
print(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.
growth
Values grow very fast
11**n balloons quickly. Start with small n (like 5) while learning — Python still handles big ints fine.
* 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.
input()
Catch ValueError
Bare int(input()) crashes on non-numeric text — wrap it in try/except ValueError.
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:print(res); res *= 11 — no if needed.
print(res): one value per row — bare print already adds the newline.
Complexity:O(n) time; O(1) extra space.
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. Python handles arbitrarily large integers, so overflow is not a concern.
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 — print first, then multiply: print(res); res *= 11 — see Example 3.
Yes — print(11 ** power) for power in range(n) gives the same sequence.
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.
Use try/except ValueError around int(input()) and require n >= 1 — see Example 2.
🤔
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. Python handles big integers automatically.