Skip to content

Instantly share code, notes, and snippets.

@gmotzespina
Created July 2, 2024 16:37
Show Gist options
  • Select an option

  • Save gmotzespina/ab0b40e2be853987106a76ceb4352d52 to your computer and use it in GitHub Desktop.

Select an option

Save gmotzespina/ab0b40e2be853987106a76ceb4352d52 to your computer and use it in GitHub Desktop.
Factorial
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