C# 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

In C# one loop is enough: keep a running res, print it, then res *= 11. No nested loops required.

How to Solve It

One loop, one running variable — print, then multiply by 11.

MethodIdeaBest for
Print then multiplyWriteLine(res); res *= 11;Cleanest loop body
If on first rowif (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

GoalPattern
Start valueint res = 1;
Loop rowsfor (i = 1; i <= n; i++)
Print lineConsole.WriteLine(res);
Next termres *= 11;

Write vs WriteLine

APIEffectUse for
Console.WriteLine(res)Prints the value and ends the linePreferred — one call per row
Console.Write(res) + WriteLine()Same result in two callsOlder textbook style (Example 1)

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 result 5 rows · last = 14641
1
11
121
1331
14641

Worked Walkthrough — n = 5

Trace res before and after each multiply.

RowPrintThen res *= 11
1111
211121
31211331
4133114641
514641161051 (not printed)

Total prints = n. For larger n, prefer long or BigInteger.

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();
            }
        }
    }
}

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);
            }
        }
    }
}

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;
            }
        }
    }
}

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.

Time and Space Complexity

ProgramTimeExtra 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).

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.

Next: Triangular Multiplication Pattern

Print row products i*1, i*2, … up to i*i.

Program 49 tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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.

6 people found this page helpful