Example 31: Number Pattern

Learn how to print a given number pattern.

We'll cover the following

Problem

Write a program to produce the following output:

1
2   3
4   5  6
7   8  9  10

Try it yourself

Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.

Get hands-on with 1400+ tech skills courses.