Java: Print a pattern like a pyramid
Pyramid with Repeating Numbers
Write a Java program to make such a pattern like a pyramid with a number that repeats in the same row.
1 2 2 3 3 3 4 4 4 4
Test Data
Input number of rows : 4
Pictorial Presentation:
Sample Solution:
Java Code:
Sample Output:
Input number of rows : 4 1 2 2 3 3 3 4 4 4 4
Flowchart:
For more Practice: Solve these Related Problems:
- Write a Java program to generate a pyramid pattern where each row’s number repeats and the pattern is centered.
- Write a Java program to create an inverted pyramid of repeating numbers and then mirror it to form a full pyramid.
- Write a Java program to produce a pyramid pattern where the repeating number is the sum of the previous row’s value.
- Write a Java program to generate a pyramid pattern with repeating numbers using a recursive method.
Java Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a program in Java to print such pattern like right angle triangle with number increased by 1. The specified pattern.
Next: Write a program in Java to print the Floyd's Triangle.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.