Recursion: Behind the Scenes
Welcome to Recursion! Hi! Welcome to this introduction to recursion, it’s great to have you here. 😀 This is a very powerful concept in programming… a function that calls itself! I know what you must be thinking: What?! The function calls itself? Why would you want to do that? 😅 Recursion is used when the result of a problem depends on the result of smaller versions of the same problem . Sounds strange? Don't worry! You will learn what it means with this tutorial. 😀 Let’s dive into the details with an example, calculating factorial. Meet Factorial 👋 The factorial of a positive integer n is the result multiplying all the integers less than or equal to n. For example, the factorial of 3 is 3 * 2 * 1 (by convention, the factorial of 0 is 1) Factorial is denoted as n! in mathematics. This is the code we will be working with. Please take a moment to analyze it. Base Case I’m sure that you noticed that there is a call to factorial...