An increasing jump number triangle starts each row at i, then jumps forward with a step m that shrinks after every print — jumps get tighter toward the end of the row.
Remember
Rule: row i starts with i
then add shrinking step m
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15 ← rows = 5, m starts at 4
Unlike the continuous counter in Program 20, each row resets its start to i and uses a fresh decreasing step.
Approach
How to Solve It
Print i first; set m = rows - 1 and k = i + m; then print k while shrinking m.
Method
Idea
Best for
Decreasing step
Start at i; jump with m -= 1
Learning, interviews
input() rows
Same loops; m = rows - 1
Interactive practice
Custom step
Fixed initial m instead of rows - 1
Variant practice
Pseudocode
Pseudocode
for i from 1 to rows:
print i (same line, spaced)
m = rows - 1
k = i + m
for j from 1 to i - 1:
print k (same line, spaced)
m = m - 1
k = k + m
print newline
Cheat sheet
Goal
Pattern
Set rows
rows = 5
Outer loop
for i in range(1, rows + 1):
Start row
print(i, end=" ")
Init step
m = rows - 1; k = i + m
Jump loop
for j in range(1, i): then print / shrink
Print + shrink
print(k, end=" "); m -= 1; k = k + m
End row
print()
Custom step
m = 3 instead of rows - 1
Printing Numbers vs Starting a New Line
API
Effect
Use for
print(i, end=" ")
Stays on the same line
Each number
print()
Ends the current line
After the jump loop
Print numbers with end=" ", then break once with print(). Putting print() inside the jump loop prints one number per line.
Try it
Live Preview
Change the row count and the jump triangle updates instantly (m starts at rows - 1).
Whole numbers from 1 to 9. Tap a chip or type a value — the preview redraws as you go.
Live result5 rows · 15 values
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15
Trace
Worked Walkthrough — rows = 3
Trace each outer value of i, the starting step m = 2, and the jumps on that row.
i
Start
Jumps (m shrinks)
Printed row
1
1
none
1
2
2
+2 → 4
2 4
3
3
+2 → 5, then +1 → 6
3 5 6
Each row resets m to rows - 1; within the row, m -= 1 makes later jumps smaller.
Code
Python Programs
Three complete programs: fixed rows = 5, input() rows, and a custom initial step. Use View Output for sample results.
Example 1 — Fixed rows = 5
Hard-coded height — each row starts at i, then jumps with m starting at 4.
Python
rows = 5
for i in range(1, rows + 1):
print(i, end=" ")
m = rows - 1
k = i + m
for j in range(1, i):
print(k, end=" ")
m -= 1
k = k + m
print()
Output
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15
How It Works
1. Start the row. Print i first — that is always the leftmost value.
2. Set the jump.m = rows - 1 and k = i + m prepare the first jump value.
3. Shrink and advance. Print k, then m -= 1 and k = k + m for each remaining slot; print() ends the row.
Example 2 — input() Rows
Read the row count at runtime; initial step scales as m = rows - 1.
Python
rows = int(input("Enter the number of rows: "))
for i in range(1, rows + 1):
print(i, end=" ")
m = rows - 1
k = i + m
for j in range(1, i):
print(k, end=" ")
m -= 1
k = k + m
print()
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. Read rows. Convert the prompt answer with int().
2. Scale the step.m = rows - 1 grows with height, so taller triangles jump farther at first.
3. Safer input tip. Bare int(input()) raises ValueError on letters. Prefer:
Safer input
raw = input("Enter the number of rows: ").strip()
try:
rows = int(raw)
except ValueError:
print("Enter a positive whole number.")
raise SystemExit(1)
if rows < 1:
print("Enter a positive whole number.")
raise SystemExit(1)
Example 3 — Custom Initial Step m = 3
Keep rows = 5 but start each row with m = 3 for tighter jumps than the default 4.
Python
rows = 5
for i in range(1, rows + 1):
print(i, end=" ")
m = 3
k = i + m
for j in range(1, i):
print(k, end=" ")
m -= 1
k = k + m
print()
Output
1
2 5
3 6 8
4 7 9 10
5 8 10 11 11
How It Works
1. Same structure. Outer loop and jump loop match Example 1.
2. Fixed seed. Only the initial m changes — m -= 1 and k = k + m still apply.
3. Compare shapes. Row lengths stay the same; values climb more slowly than with m = rows - 1.
Edge Cases & Pitfalls
Check these before calling the solution done.
m outside
Step not reset
If m is set once before the outer loop, later rows inherit a tiny step. Reset m at the start of every row.
order
Wrong update order
Print k, then m -= 1, then k = k + m. Updating k before decreasing m uses the wrong step.
print() inside
Vertical numbers
If print() is inside the jump loop, each number lands on its own line.
rows = 1
Single number
Output is just 1 — the jump loop never runs.
rows ≤ 0
Empty output
The outer loop never runs. Guard interactive input with rows >= 1.
input()
Catch ValueError
Letters crash bare int(input()) — wrap in try/except and require rows >= 1.
Analysis
Time and Space Complexity
Program
Time
Extra space
Examples 1–3
O(n²)
O(1)
Total numbers printed = 1 + 2 + … + n = n(n+1)/2 → O(n²).
Remember
Key Takeaways
Rule: row i starts with i, then jumps with a shrinking step m.
Reset m: set m = rows - 1 at the start of every row.
end= vs print(): numbers stay on the line; print() advances after each row.
Complexity:O(n²) for n rows.
One line: print i, then keep adding a step that gets one smaller after every jump.
Frequently Asked Questions
Because the step variable 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 in the row. It decreases each time, changing the increment between consecutive outputs.
Row 2 prints i = 2 first. Then m = 4 and k = i + m = 6 — the inner loop prints k once, giving 2 6.
print(i, end=" ") stays on the same line with a trailing space. print() ends the current line. Numbers use end=" "; the row break uses print() after the jump loop.
Total prints are 1+2+…+n = n(n+1)/2 — row i prints exactly i values.
Yes. Set m to a custom value instead of rows - 1 (see Example 3) — smaller steps produce tighter jumps.
O(n²) for n rows because total digit prints equal n(n+1)/2.
Use try/except ValueError around int(input()) so bad input does not crash the script.
The outer loop never runs, so nothing is printed. Validate and prompt again if you want a clear user message.
🤔
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.