You can download this code by clicking the button below.
This code is now available for download.
Calculates the factorial of a non-negative integer
Technology Stack : math (mathematical calculations), random (random number generation)
Code Type : Function
Code Difficulty : Intermediate
import random
import math
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)