Factorial in Python

update me anything

Factorial in Python

This Python code calculates the factorial of a number.

def factorial(n):    if n == 0:        return 1    else:        return n * factorial(n - 1)print(factorial(5))

The output of the code is 120.


Post a Comment (0)
Previous Post Next Post