Given a positive integer n. Task is to print the pyramid pattern as described in the examples below.
Input : 2 Output : 1 22 1 Input : 3 Output : 1 22 333 22 1 Input : 5 Output : 1 22 333 4444 55555 4444 333 22 1
//Print All Pattern printPattern(int N) // Print upper pattern /* 1 22 333 ... N...(N)times */ for i->1 to N for j->1 to i print i print next line // Print lower triangle /* N-1....(N-1)times ... 333 22 1 */ for i->N-1 to 0 for j->i to 0 print i print next line
1 22 333 4444 55555 666666 7777777 88888888 7777777 666666 55555 4444 333 22 1
This article is contributed by Sahil Rajput. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Program to print pyramid pattern
- Program to Print Pyramid Pattern using numbers
- Program to print hollow pyramid and diamond pattern
- Program to print a inverse pyramid character pattern
- Print the following pyramid pattern
- Print the pyramid pattern with given height and minimum number of stars
- Program to print Even Odd Number Pyramid
- Program to print the pattern "GFG"
- Program to print the pattern 'G'
- Program to print the pattern ‘D’
- Program to print pattern
- Program to print the given H Pattern
- Program to print the given Z Pattern
- Program to print numeric pattern | Set - 2
- Program to Print the Trapezium Pattern
Improved By : Mithun Kumar