Increasing Jump Number Triangle in C#

What You’ll Learn
How to print an increasing jump number triangle in C# where each row starts with the row index and then “jumps” forward using a decreasing step size.
For 5 rows, the output is: 1, 2 6, 3 7 10, 4 8 11 13, 5 9 12 14 15.
⭐ Pattern Output
For rows = 5, the pattern looks like this:
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15Complete C# Program
Start each row with i, then compute next values by adding a step m that decreases inside the row.
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
int i, j, k, m;
for (i = 1; i <= 5; i++)
{
Console.Write(i + " ");
m = 4;
k = i + m;
for (j = 1; j < i; j++)
{
Console.Write(k + " ");
m--;
k = k + m;
}
Console.WriteLine();
}
}
}
}🧠 How It Works
Print the first value
Each row starts by printing i.
Initialize step and next value
m = 4 and k = i + m set up the first jump in that row.
Decrease the step after each print
After printing k, we do m-- and then k = k + m to compute the next jump.
Jumping sequence per row
Each row prints exactly i values, so total prints are \(1+2+\dots+n\).
Variation — Configurable Rows
Make the size dynamic by using rows and setting the initial step to rows - 1:
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter the number of rows: ");
int rows = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <= rows; i++)
{
Console.Write(i + " ");
int m = rows - 1;
int k = i + m;
for (int j = 1; j < i; j++)
{
Console.Write(k + " ");
m--;
k = k + m;
}
Console.WriteLine();
}
}
}
}💡 Tips for Enhancement
Try These
- Remove trailing spaces by printing spaces only between numbers
- Store row values in a list first if you want more control over formatting
- Experiment with different starting steps to create new “jump” patterns
Avoid
- Forgetting to reset
mandkfor each row - Letting
rowsbe 0 or negative (validate input in real apps)
Key Takeaways
Each row starts with i, then computes future values with a step.
The step m decreases each time, so jumps shrink across the row.
Total prints are triangular: \(1+2+\dots+n\).
Overall runtime is \(O(n^2)\) for n rows.
❓ Frequently Asked Questions
m controls how much to jump to the next number. Decreasing m changes the jump sizes inside the row.n(n+1)/2.Explore More C# Number Patterns!
Jump-style patterns are a fun way to practice variables that change inside nested loops.
Some number patterns can be generated by controlling differences between consecutive values. Here, that difference is the variable m.
12 people found this page helpful
