{"id":"83222b79-a02d-4a90-b673-b73052a8f855","name":"Print Decreasing","description":"1. You are given a positive number n. \r\n2. You are required to print the counting from n to 1.\r\n3. You are required to not use any loops. Complete the body of print Decreasing function to achieve it.\r\n\r\nNote -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.","inputFormat":"A number n","outputFormat":"n\r\nn - 1\r\nn - 2\r\n.. \r\n1","constraints":"1 &lt;= n &lt;= 1000","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\n\r\nvoid printDecreasing(int n){\r\n // write your code here\r\n \r\n}\r\n\r\nint main(){\r\n int n;\r\n cin >> n;\r\n printDecreasing(n);\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n public static void printDecreasing(int n){\r\n \r\n }\r\n\r\n}"},"python":{"code":"def printDecreasing(n):\n # write your code here\n\nn = int(input())\nprintDecreasing(n)"}},"points":10,"difficulty":"easy","sampleInput":"5","sampleOutput":"5\r\n4\r\n3\r\n2\r\n1","questionVideo":"https://www.youtube.com/embed/5Q5ed7PWJ8I","hints":[],"associated":[{"id":"21d6e06c-65ac-48e8-930e-492a31a732bb","name":"(Print Decreasing) what is the output if n==3?","slug":"print-decreasing-what-is-the-output-if-n-3","type":4},{"id":"a8dccc6f-f085-427a-b856-003c469224de","name":"(Print Decreasing) What will be the base condition?","slug":"print-decreasing-what-will-be-the-base-condition","type":4},{"id":"d652dcdb-474c-4200-a194-0af7c26ab10c","name":"(Print Decreasing) What will be the recursive call?","slug":"print-decreasing-what-will-be-the-recursive-call","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"d341a7c9-1269-409c-b851-0bb512289544","name":"Recursion And Backtracking For Beginners","slug":"recursion-and-backtracking-for-beginners","type":0},{"id":"6a915f2c-d6fd-4561-9cda-fceabe22db40","name":"Print Decreasing","slug":"print-decreasing","type":1}],"next":{"id":"e32076e8-b111-4dbe-a514-2e7782981dc8","name":"Print Decreasing","type":3,"slug":"print-decreasing"},"prev":null}}

Print Decreasing

1. You are given a positive number n. 2. You are required to print the counting from n to 1. 3. You are required to not use any loops. Complete the body of print Decreasing function to achieve it. Note -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.

{"id":"83222b79-a02d-4a90-b673-b73052a8f855","name":"Print Decreasing","description":"1. You are given a positive number n. \r\n2. You are required to print the counting from n to 1.\r\n3. You are required to not use any loops. Complete the body of print Decreasing function to achieve it.\r\n\r\nNote -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.","inputFormat":"A number n","outputFormat":"n\r\nn - 1\r\nn - 2\r\n.. \r\n1","constraints":"1 &lt;= n &lt;= 1000","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\n\r\nvoid printDecreasing(int n){\r\n // write your code here\r\n \r\n}\r\n\r\nint main(){\r\n int n;\r\n cin >> n;\r\n printDecreasing(n);\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n public static void printDecreasing(int n){\r\n \r\n }\r\n\r\n}"},"python":{"code":"def printDecreasing(n):\n # write your code here\n\nn = int(input())\nprintDecreasing(n)"}},"points":10,"difficulty":"easy","sampleInput":"5","sampleOutput":"5\r\n4\r\n3\r\n2\r\n1","questionVideo":"https://www.youtube.com/embed/5Q5ed7PWJ8I","hints":[],"associated":[{"id":"21d6e06c-65ac-48e8-930e-492a31a732bb","name":"(Print Decreasing) what is the output if n==3?","slug":"print-decreasing-what-is-the-output-if-n-3","type":4},{"id":"a8dccc6f-f085-427a-b856-003c469224de","name":"(Print Decreasing) What will be the base condition?","slug":"print-decreasing-what-will-be-the-base-condition","type":4},{"id":"d652dcdb-474c-4200-a194-0af7c26ab10c","name":"(Print Decreasing) What will be the recursive call?","slug":"print-decreasing-what-will-be-the-recursive-call","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"d341a7c9-1269-409c-b851-0bb512289544","name":"Recursion And Backtracking For Beginners","slug":"recursion-and-backtracking-for-beginners","type":0},{"id":"6a915f2c-d6fd-4561-9cda-fceabe22db40","name":"Print Decreasing","slug":"print-decreasing","type":1}],"next":{"id":"e32076e8-b111-4dbe-a514-2e7782981dc8","name":"Print Decreasing","type":3,"slug":"print-decreasing"},"prev":null}}
plane

Editor


Loading...

Print Decreasing

easy

1. You are given a positive number n. 2. You are required to print the counting from n to 1. 3. You are required to not use any loops. Complete the body of print Decreasing function to achieve it. Note -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.

Constraints

1 <= n <= 1000

Format

Input

A number n

Output

n n - 1 n - 2 .. 1

Example

Sample Input

5

Sample Output

5 4 3 2 1

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode