Python Factorial Calculator

  • Share this:

Code introduction


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)