Showing posts with label Coding. Show all posts
Showing posts with label Coding. Show all posts

Thursday, 26 May 2016

How to print Pyramid Pattern of Numbers in Java

Write a Java Program to print the following Pyramid pattern of numbers:

1
12
123
1234
12345
1234
123
12
1

You can easily print above pattern using two loops and with the help of print() and println() method of PrintStream. You can access them using System.out object as System.out.print() and System.out.println().

But, in this program, I'll show you can print this patter by using just one loop instead of two.