From the course: Python: Recursion
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
A recursive factorial function - Python Tutorial
From the course: Python: Recursion
A recursive factorial function
- [Instructor] Now that you know how to implement the factorial function using iteration, we're going to see how to do the same thing recursively. You need to open up the file factorial recursive in your exercise files. And if you're using git, git checkout. And I'm going to put this b flagged there which you don't need because you're not creating this but I'm creating this as I go. So that's going to be git checkout -b and it's going to be 02_04b for beginning. Like I say this b here is when you're creating the branch and checking it out in one command. Whereas you just need to check out the branch which is already being created. So I know on my new branch. And I'm ready to go so let's close it up. So, recursive factorial. First of all we need a base case so if n is less than or equal to a one. Let's make a note that this is in fact the base case using a comment. So if it's the base case is then, we want to return…
Contents
-
-
-
-
(Locked)
Exceptions to GitHub Codespaces1m 30s
-
(Locked)
The ingredients of a recursive algorithm4m 11s
-
Recursion in action3m 26s
-
(Locked)
The factorial function: Iterative version3m 26s
-
(Locked)
A recursive factorial function4m 13s
-
(Locked)
Winding and unwinding the call stack in recursion6m 46s
-
(Locked)
Challenge: Fix the recursive algorithm1m 11s
-
(Locked)
Solution: The fundamentals of recursion1m 8s
-
(Locked)
-
-
-
-
-
-
-
-