VOOZH about

URL: https://www.geeksforgeeks.org/dsa/inner-reducing-pattern-printing/

⇱ Inner reducing pattern printing - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Inner reducing pattern printing

Last Updated : 2 Mar, 2023

Given a number N, print the following pattern. Examples :

Input : 4
Output : 4444444
 4333334
 4322234
 4321234
 4322234
 4333334
 4444444
Explanation:
(1) Given value of n forms the outer-most
 rectangular box layer.
(2) Value of n reduces by 1 and forms an 
inner rectangular box layer.
(3) The step (2) is repeated until n 
reduces to 1.

Input : 3
Output : 33333
 32223
 32123
 32223
 33333

Output :

4444444
4333334
4322234
4321234
4322234
4333334
4444444
Comment