An increasing number triangle from 11 prints a growing left-aligned triangle where each value is 9 + i + j — so the first cell is 11, not 1.
Remember
Rule: print (9 + i + j) with a trailing space
11
12 13
13 14 15
14 15 16 17
15 16 17 18 19 ← 5 rows
In C# the outer loop grows the row length; the inner loop prints i values per row. Change the base 9 to shift the whole triangle.
Approach
How to Solve It
One nested-loop idea with a fixed or custom base offset.
Method
Idea
Best for
Fixed base 9
Print 9 + i + j on each cell
Learning, interviews, exams
Custom base
Replace 9 with a user-supplied offset
Practice / variants
Pseudocode
Pseudocode
for i from 1 to rows:
for j from 1 to i:
print (9 + i + j) and a space
print newline
Cheat sheet
Goal
Pattern
Grow the row
for (i = 1; i <= rows; i++)
Print i values
for (j = 1; j <= i; j++)
Cell value
Console.Write((9 + i + j) + " ");
Custom base
Console.Write((baseVal + i + j) + " ");
End the row
Console.WriteLine();
Write vs WriteLine
API
Effect
Use for
Console.Write
Stays on the same line
Each number + space
Console.WriteLine
Ends the current line
After the inner loop
Try it
Live Preview
Change the row count and the triangle updates instantly — including the total value count.
Whole numbers from 1 to 9. Tap a chip or type a value — the preview redraws as you go.
Live result5 rows · 15 values
11
12 13
13 14 15
14 15 16 17
15 16 17 18 19
Trace
Worked Walkthrough — rows = 4
Trace each cell with the formula 9 + i + j.
i
Values of j
Printed row
1
9+1+1 = 11
11
2
12, 13
12 13
3
13, 14, 15
13 14 15
4
14 … 17
14 15 16 17
Row i always prints i numbers. Notice consecutive rows overlap in values — that is expected from the formula.
Code
C# Programs
Three complete programs: fixed height, custom base with user input, and a compact 3-row demo. Use View Output for sample results.
Example 1 — Fixed rows = 5
Nested loops print 9 + i + j with a trailing space on each cell.
C#
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
int i, j;
for (i = 1; i <= 5; i++)
{
for (j = 1; j <= i; j++)
Console.Write((9 + i + j) + " ");
Console.WriteLine();
}
}
}
}
Output
11
12 13
13 14 15
14 15 16 17
15 16 17 18 19
How It Works
1. Outer loop.i grows from 1 to 5 — each pass adds one more number to the row.
2. Formula.9 + i + j yields 11 on the first cell, then climbs across each row.
3. Newline.WriteLine() after the inner loop starts the next longer row.
Example 2 — User Input (rows + base)
Read the row count and a custom base offset so the triangle can start anywhere.
C#
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
int rows, baseVal;
int i, j;
Console.Write("Enter rows: ");
if (!int.TryParse(Console.ReadLine(), out rows) || rows < 1)
{
Console.WriteLine("Please enter a positive whole number for rows.");
return;
}
Console.Write("Enter base: ");
if (!int.TryParse(Console.ReadLine(), out baseVal))
{
Console.WriteLine("Please enter a whole number for base.");
return;
}
for (i = 1; i <= rows; i++)
{
for (j = 1; j <= i; j++)
Console.Write((baseVal + i + j) + " ");
Console.WriteLine();
}
}
}
}
Output (when user enters rows 3, base 9)
Enter rows: 3
Enter base: 9
11
12 13
13 14 15
How It Works
1. Validate input.TryParse handles both prompts; require rows >= 1.
2. Same formula.baseVal + i + j with base 9 matches Example 1; try base 10 to start at 12.
Example 3 — Compact rows = 3
A smaller fixed demo — same formula, easier to trace by hand.
C#
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
int rows = 3;
int i, j;
for (i = 1; i <= rows; i++)
{
for (j = 1; j <= i; j++)
Console.Write((9 + i + j) + " ");
Console.WriteLine();
}
}
}
}
Output
11
12 13
13 14 15
How It Works
1. Same rules. Outer grows length; inner prints 9 + i + j with a space.
2. Quick check. Three rows end at 13 14 15.
Edge Cases & Pitfalls
Check these before calling the solution done.
wrong formula
Print i + j without the base
That starts at 2, not 11. Keep the offset: 9 + i + j.
missing space
Forget the trailing space
Numbers glue together (1213). Always append " " in Write.
WriteLine early
WriteLine inside the inner loop
That puts each number on its own line. Call WriteLine() only after the inner loop.
rows = 1
Single 11
Output is just 11 (plus a trailing space).
rows ≤ 0
Empty output
The outer loop never runs. Validate and prompt again for clearer UX.
Bad input
Convert.ToInt32 throws
Prefer int.TryParse so non-numeric input does not crash the program.
Analysis
Time and Space Complexity
Program
Time
Extra space
Fixed / compact (Examples 1, 3)
O(n²)
O(1)
Custom base (Example 2)
O(n²)
O(1)
Total printed values are 1 + 2 + … + n = n(n+1)/2, which is quadratic in n.
Remember
Key Takeaways
Rule: print 9 + i + j with a trailing space on each cell.
Shape: row i prints exactly i numbers — a classic left triangle.
Write vs WriteLine: numbers stay on the line; WriteLine advances after each row.
Next step: Program 33 uses i + j - 1 so the triangle starts at 1.
One line: for each row i, print i values of 9 + i + j to build an increasing triangle from 11.
Frequently Asked Questions
Because the printed value is 9 + i + j. On the first row i = 1 and j = 1, so 9 + 1 + 1 = 11.
It is a base offset. Change 9 to any base value to shift the entire triangle — see Example 2.
Program 32 uses 9 + i + j (starts at 11). Program 33 uses i + j - 1 (starts at 1).
Console.Write((9 + i + j) + " ") keeps values separated on the same row. WriteLine ends the row.
Replace 5 with rows in the outer loop bound — see Example 2.
O(n²) for n rows because total prints are 1 + 2 + ... + n = n(n+1)/2.
Prefer int.TryParse(Console.ReadLine(), out rows) so bad input does not throw FormatException.
Only one row prints — a single 11.
Yes — Console.Write((baseVal + i + j) + " ") lets the user pick any starting offset.
🤔
Did you know?
Each printed value is computed as 9 + i + j. Row i = 1 prints 11; row i = 2 prints 12 and 13 — a left-shifted increasing triangle.