![]() |
In this article, we will see how to print N to 1 using Recursion in JavaScript. What is Recursion?The process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called a recursive function. In the recursive program, the solution to the base case is provided and the solution to the bigger problem is expressed in terms of smaller problems. Examples: Input : N = 10 Approach:
Example: In this example, we will print N to 1 using Recursion in JavaScript. Javascript
Output
8 7 6 5 4 3 2 1 Time Complexity: O(N) Space Complexity: O(N) |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |