How to print in Pyramid of Numbers in Java?

uzairadamjee / February 8, 2018

Below programs display the pyramid of numbers based on user input

// Library to import

import java.util.Scanner;

Scanner input = new Scanner (; // for taking input from user

System.out.println("Enter the Input Number that how many times do you want to get pyramid of numbers : ");

int inputNumber = input.nextInt();// take input from user

for (int row = 1  ; row <= inputNumber; row++){

for (int space = inputNumber-1; space>=row; space--)

System.out.print(" ");

for (int left = row; left <= row+(row-1); left++)


for(int right = (row-3)+(row+1); right >= row; right--)




Leave a Reply

Your email address will not be published.