You can download this code by clicking the button below.
This code is now available for download.
Calculate the factorial of a given non-negative integer. The factorial is denoted as n!, which represents the product of all positive integers up to n.
Technology Stack : Recursion
Code Type : Recursive function
Code Difficulty : Intermediate
def factorial(n, acc=1):
if n == 0:
return acc
else:
return factorial(n-1, n*acc)