Answers for "how to calculate factoral in python"

20

python calculate factorial

def factorial(n):
    fact = 1
    for num in range(2, n + 1):
        fact = fact * num
    return(fact)
Posted by: Guest on May-24-2020
1

Python function to compute factorial of a number.

def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n-1)
n=int(input("Input a number to compute the factiorial : "))
print(factorial(n))
Posted by: Guest on March-12-2022

Code answers related to "how to calculate factoral in python"

Python Answers by Framework

Browse Popular Code Answers by Language