Created
July 2, 2024 16:37
-
-
Save gmotzespina/ab0b40e2be853987106a76ceb4352d52 to your computer and use it in GitHub Desktop.
Factorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def factorial(num): | |
| # Base case | |
| if num == 0: | |
| return 1 | |
| # Recursive step | |
| else: | |
| return num * factorial(num - 1) | |
| print(factorial(3)) # Output: 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment