VOOZH about

URL: https://www.geeksforgeeks.org/dsa/program-to-print-diamond-pattern-using-numbers-and-stars/

⇱ Program to print diamond pattern using numbers and stars - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Program to print diamond pattern using numbers and stars

Last Updated : 31 Oct, 2023

Program to print the following pattern of a half diamond for N.

👁 Image
Pattern for N = 4

Example:

Input: N = 5
Output: 

1

2*3

4*5*6

7*8*9*10

11*12*13*14*15

11*12*13*14*15

7*8*9*10

4*5*6

2*3

1

This program is divided into four parts.


Output
1
2*3
4*5*6
7*8*9*10
7*8*9*10
4*5*6
2*3
1

Time Complexity: O(N2
Auxiliary Space:  O(1) since we are not using any extra space

Comment
Article Tags: