An increasing jump number triangle starts each row at i, then jumps forward with a step m that shrinks after every print.
Remember
Rule: for i from 1 to rows
print i
m = rows - 1; k = i + m
print (i - 1) jumps: k, then m--, k += m
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15 ← rows = 5
Follows the continuous counter triangle in Program 20; next is odd-length number rows in Program 22.
Approach
How to Solve It
Print i first. Reset m = rows - 1 and k = i + m each row, then loop i - 1 times with m-- and k += m.
Method
Idea
Best for
Shrink step m
Start at rows - 1; after each jump do m-- then k += m
Learning, interviews, exams
Custom step
Set m to a fixed start (e.g. 3) instead of rows - 1
Tighter or wider jumps
Pseudocode
Pseudocode
for i from 1 to rows:
print i and a space
m = rows - 1
k = i + m
for j from 1 to i - 1:
print k and a space
m = m - 1
k = k + m
print newline
Cheat sheet
Goal
Pattern
Grow each row
for (i = 1; i <= rows; i++)
Print row start
cout << i << " ";
Init jump
m = rows - 1; k = i + m;
Jump loop
for (j = 1; j < i; j++)
Shrink step
m--; k = k + m; after each print
Printing Numbers vs Starting a New Line
API
Effect
Use for
cout << k << " "
Stays on the same line
Each number on the row
cout << "\n"
Ends the current line
After the jump loop finishes
Print numbers without a newline, then end the row once.
Try it
Live Preview
Change the row count and the jump number triangle updates instantly — capped at 9 for readable demos.
Whole numbers from 1 to 9. Tap a chip or type a value — the preview redraws as you go.
Live resultrows = 5 · 15 numbers
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15
Trace
Worked Walkthrough — rows = 5
Trace how printing i then shrinking m builds each jump row.
i
Start m
Sequence
Prints
1
4
1
1
2
4
2, 6
2 6
3
4
3, 7, 10
3 7 10
4
4
4, 8, 11, 13
4 8 11 13
5
4
5, 9, 12, 14, 15
5 9 12 14 15
Total numbers = n(n+1)/2 → O(n²). Reset m at the start of every row.
Code
C++ Programs
Three complete programs: fixed rows = 5, cin input, and a compact rows = 3 demo. Use View Output to reveal sample results.
Example 1 — Fixed rows = 5
Hard-coded height — print i, then i - 1 jumps with shrinking m.
C++
#include <iostream>
using namespace std;
int main()
{
int rows = 5;
int i, j, k, m;
for (i = 1; i <= rows; i++)
{
cout << i << " ";
m = rows - 1;
k = i + m;
for (j = 1; j < i; j++)
{
cout << k << " ";
m--;
k = k + m;
}
cout << "\n";
}
return 0;
}
Output
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15
How It Works
1. Print the row start.cout << i << " " puts the row index first.
2. Init the jump.m = rows - 1 and k = i + m set up the first jump value.
3. Shrink and advance. Print k, then m-- and k = k + m; newline after the jump loop.
Example 2 — User Input Rows
Read rows with cin, validate, then set m = rows - 1 each row.
C++
#include <iostream>
using namespace std;
int main()
{
int rows;
int i, j, k, m;
cout << "Enter the number of rows: ";
if (!(cin >> rows) || rows <= 0)
{
cout << "Please enter a positive integer.\n";
return 1;
}
for (i = 1; i <= rows; i++)
{
cout << i << " ";
m = rows - 1;
k = i + m;
for (j = 1; j < i; j++)
{
cout << k << " ";
m--;
k = k + m;
}
cout << "\n";
}
return 0;
}
Output (when user enters 4)
Enter the number of rows: 4
1
2 5
3 6 8
4 7 9 10
How It Works
1. Prompt and validate. Reject failed reads and non-positive values before printing.
2. Same core. Shrink-step jumps match Example 1 — only rows comes from the user.
3. Safer input tip. Cap demos for readable output:
Safer input
if (!(cin >> rows) || rows < 1 || rows > 9)
{
cout << "Enter a whole number from 1 to 9.\n";
return 1;
}
Example 3 — Compact rows = 3
Same structure with only three rows — easy to confirm start + jump logic.
C++
#include <iostream>
using namespace std;
int main()
{
int rows = 3;
int i, j, k, m;
for (i = 1; i <= rows; i++)
{
cout << i << " ";
m = rows - 1;
k = i + m;
for (j = 1; j < i; j++)
{
cout << k << " ";
m--;
k = k + m;
}
cout << "\n";
}
return 0;
}
Output
1
2 4
3 5 6
How It Works
1. Three rows.i = 1 → 1; i = 2 → 2 4; i = 3 → 3 5 6.
2. Trace on paper. If you skip m--, every jump stays the same size and the pattern breaks.
3. Scale up next. Once the small demo is clear, use Examples 1–2 for five rows or user input.
Edge Cases & Pitfalls
Check these before calling the solution done.
no m--
Constant jump size
Skipping m-- keeps every jump the same. Always decrease m before updating k.
carry m
Forgot to reset m
Set m = rows - 1 at the start of every outer iteration — do not carry it from the previous row.
j <= i
One too many jumps
Use for (j = 1; j < i; j++) — only i - 1 jumps after printing i.
\n inside
Broken rows
If cout << "\n" sits inside the jump loop, each number lands on its own line. Call it only after the row finishes.
rows = 1
Single number
Output is just 1 — the jump loop never runs. A good sanity check for input validation.
cin
Check the stream
Validate cin >> rows before looping — a failed read leaves rows unset or stale.
Analysis
Time and Space Complexity
Program
Time
Extra space
Fixed / input (Examples 1–2)
O(n²)
O(1)
Compact rows = 3 (Example 3)
O(n²)
O(1)
Total numbers printed = 1 + 2 + … + n = n(n+1)/2 → O(n²) time. Only a few loop variables are needed.
Remember
Key Takeaways
Start with i: print the row index first, then compute jumps.
Shrink m: reset m = rows - 1 each row; after each jump do m-- then k += m.
Break the row:cout << k << " " in the jump loop; cout << "\n" after it.
Complexity:O(n²) time from n(n+1)/2 numbers; O(1) extra space.
One line: for each row i, print i, then i - 1 jumps with a shrinking step m, then newline.
Frequently Asked Questions
An increasing jump triangle: for rows=5 you get 1 / 2 6 / 3 7 10 / 4 8 11 13 / 5 9 12 14 15 — each row starts at i, then jumps with a shrinking step.
Because the step m starts at rows - 1 and decreases after each printed number. Each next value adds the current m, so jumps shrink across the row.
m is the step size used to compute the next printed number. It starts at rows - 1 and decreases after every jump print.
Row 2 prints i = 2 first. Then m = 4 and k = i + m = 6 — the inner loop prints k once, giving 2 6.
cout << k << " " stays on the same line with a space. cout << "\n" ends the current line. Numbers use cout; the row break uses cout << "\n" after the inner loop.
Yes. Set m to a custom value instead of rows - 1 — smaller steps produce tighter jumps.
After prompting, use if (!(cin >> rows) || rows <= 0) to reject bad input before printing.
O(n²) for n rows because total prints are 1+2+…+n = n(n+1)/2.
🤔
Did you know?
Each row starts at i, then adds a decreasing step m to compute the next value. As m shrinks after each print, the jumps get smaller toward the end of the row — total prints still equal n(n+1)/2 for n rows.