JavaScript Powers of 11 Number Pattern

Beginner
5 min read
Updated: Sep 2026
3 programs
Live preview

What Is This Pattern?

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

Unlike Program 47 (2D concentric diamond), this is a 1D sequence — one loop, one running variable, no nested loops.

How to Solve It

One loop, one running variable — log the current value, then multiply by 11.

MethodIdeaBest for
Running productconsole.log(res); res *= 11;Classic demos
Exponentiationconsole.log(11 ** power) for power = 0..n-1Direct formula

Pseudocode

Pseudocode
res = 1
repeat n times:
    print res
    res = res * 11

Cheat sheet

GoalPattern
Start valuelet res = 1;
Loop rowsfor (let i = 0; i < n; i++)
Print termconsole.log(res);
Next termres *= 11;
By powerconsole.log(11 ** power);

Printing Numbers vs Starting a New Line

APIEffectUse for
line += …Stays on the same rowNot needed here — one number per row
console.log(res)Prints the value and ends the rowEach power-of-11 term

Same idea as C# WriteLine(res): each term is a complete line by itself.

Live Preview

Change the row count and the powers-of-11 sequence updates instantly.

Whole numbers from 1 to 10. Beyond that, prefer BigInt for exact values. Tap a chip or type a value — the preview redraws as you go.

Live result n = 5 · last = 14641
1
11
121
1331
14641

Worked Walkthrough

Trace the first four rows — watch res before and after *= 11.

RowPrint resThen res *= 11
1111
211121
31211331
4133114641

Order matters: log first, then multiply — otherwise the first line becomes 11.

JavaScript Programs

Three complete programs: fixed n = 5, prompt input, and an exponentiation approach. Use View Output for samples, or Try It Yourself to edit and run live.

Example 1 — Fixed n = 5

Print the current term, then multiply by 11 for the next row.

JavaScript
const n = 5;
let res = 1;

for (let i = 0; i < n; i++) {
  console.log(res);
  res *= 11;
}
Try It Yourself

How It Works

1. Start at 1. res = 1 is 11^0 — the first line.

2. Log, then multiply. console.log(res) prints the current term; res *= 11 prepares the next.

3. Repeat n times. Five iterations produce 1, 11, 121, 1331, 14641.

Example 2 — User Input Rows

Read n with prompt and validate before printing.

JavaScript
const n = parseInt(prompt("Enter number of rows:"), 10);
let res = 1;

if (!Number.isFinite(n) || n < 1) {
  console.log("Please enter a positive integer.");
} else {
  for (let i = 0; i < n; i++) {
    console.log(res);
    res *= 11;
  }
}
Try It Yourself

How It Works

1. Prompt and validate. Use parseInt and require n >= 1.

2. Same sequence core. Only the source of n changes — print then multiply matches Example 1.

3. Entering 4. Four lines ending at 1331 (11^3).

Example 3 — Exponentiation

Compute each term as 11 ** power with no running product.

JavaScript
const n = 5;

for (let power = 0; power < n; power++) {
  console.log(11 ** power);
}
Try It Yourself

How It Works

1. Power from 0. 11 ** 0 is 1 — same first line as Example 1.

2. No running state. Each row is independent — useful when you need a single term by index.

3. Same sequence. For small n, results match res *= 11 exactly.

Edge Cases & Pitfalls

Check these before calling the solution done.

Order

Log before multiplying

If you do res *= 11 before printing when res starts at 1, the first line becomes 11.

Precision

Number loses exactness for large n

Past roughly 15 safe digits, use BigInt (1n and *= 11n) for exact values.

Wrong factor

Keep the factor 11

Multiplying by 10 gives 1, 10, 100, 1000… — a different pattern.

n = 1

Single-row case

Output is just 1 — valid and useful for testing.

Time and Space Complexity

ProgramTimeExtra space
Running product (Examples 1–2)O(n)O(1)
Exponentiation (Example 3)O(n)O(1)

One value per row — linear in n. Extra space is constant aside from printing.

Key Takeaways

  • Rule: start at 1; each next line multiplies the previous value by 11.
  • Clean loop: console.log(res); res *= 11; — no if needed.
  • Alt: console.log(11 ** power) for power = 0..n-1.
  • Complexity: O(n) time — one term per row.

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 prompt(). For very large n, use BigInt to avoid Number precision limits.
11^n shows binomial digits only while there are no base-10 carries. Once carries occur, digits no longer match the triangle.
This pattern needs only console.log — one full number per row. There is nothing to append mid-line.
Program 47 prints a 2D concentric diamond with nested loops. Program 48 prints a 1D growing sequence with one loop.
Yes — console.log(11 ** power) for power from 0 to n-1 gives the same sequence — see Example 3.
O(n) for n rows because the program computes and logs one value per row.
161051 — still valid, but digit carries mean it no longer mirrors Pascal row coefficients.

Did you know?

Start with let res = 1, log 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.

Next: Multiplication Triangle Pattern

Continue with the next pattern in the JavaScript number-pattern series.

Program 49 tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful