• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
November 27, 2023 |3.3K Views
PROBLEM OF THE DAY : 26/11/2023 | Print Pattern
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Siddharth Hazra. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Recursion but also build up problem-solving skills.

In this problem, we are given to print a sequence of numbers starting with N, without using a loop, where to replace N with N - 5, until N > 0. After that replace N with N + 5 until N regains its initial value.

Example :

Input: 
N = 16
Output: 
16 11 6 1 -4 1 6 11 16

Explanation: 
The value decreases until it is greater than 0. After that, it increases and stops when it becomes 16 again.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/print-pattern3549/1