Given an integer N, the task is to print the below pattern for the given value of N.
For N = 5 Below is the given pattern:
Input: N = 4
Input: N = 3
Approach: The idea is to understand the logic behind the given pattern is stated below:
\By looking closely we see that by replacing in-between zeroes with spaces the pattern can be seen more clearly. The pattern is further divided into three different patterns.
- Case 1: Asterisk (*) character pattern follows a sequence from 0 and adding two more asterisks in each row, where the row is equal to N.
- Case 2: In this part, the pattern is very simple to understand i.e the number of columns and rows will be equal to N and follows a sequence like 1, 2, 3, 4, 5…
- Case 3: Follow-up or bottom-up sequence is its interesting part where the numbers are represented from bottom to top.
Below is the implementation of the above approach:
102030405026027028029030 **6070809022023024025 ****10011012019020021 ******13014017018 ********15016
Time Complexity: O(N2)
Auxiliary Space: O(1)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Program to print a pattern of numbers
- Python Program to print digit pattern
- Program to print pyramid pattern
- Program to print hollow pyramid and diamond pattern
- C Program to print pyramid pattern
- Program to print a rectangle pattern
- Program to print interesting pattern
- Program to print number pattern
- Program to print number with star pattern
- Program to print reverse character bridge pattern
- Program to print numbers with diamond pattern
- Program to print a inverse pyramid character pattern
- Program to print the pattern 'G'
- Program to print the pattern ‘D’
- Program to print double headed arrow pattern
- Program to print V and inverted-V pattern
- Program to print the arrow pattern
- Python 3 | Program to print double sided stair-case pattern
- Program to print Swastika Pattern
- Program to print the pattern "GFG"
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.