Increasing Jump Number Triangle in C#

Beginner
⏱️ 7 min read
📚 Updated: Aug 2025
🎯 2 Code Examples
Decreasing Step

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:

Output
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15
1

Complete C# Program

Start each row with i, then compute next values by adding a step m that decreases inside the row.

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

1

Print the first value

Each row starts by printing i.

Row start
2

Initialize step and next value

m = 4 and k = i + m set up the first jump in that row.

Setup
3

Decrease the step after each print

After printing k, we do m-- and then k = k + m to compute the next jump.

Decreasing step
=

Jumping sequence per row

Each row prints exactly i values, so total prints are \(1+2+\dots+n\).

2

Variation — Configurable Rows

Make the size dynamic by using rows and setting the initial step to rows - 1:

C#
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 m and k for each row
  • Letting rows be 0 or negative (validate input in real apps)

Key Takeaways

1

Each row starts with i, then computes future values with a step.

2

The step m decreases each time, so jumps shrink across the row.

3

Total prints are triangular: \(1+2+\dots+n\).

4

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.
Yes, but you’d need another way to compute the changing increments. Using a decreasing step is the simplest approach here.
O(n²) for n rows since total prints are n(n+1)/2.

Explore More C# Number Patterns!

Jump-style patterns are a fun way to practice variables that change inside nested loops.

All Number Patterns →
Did you know?

Some number patterns can be generated by controlling differences between consecutive values. Here, that difference is the variable m.

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.

12 people found this page helpful