Answers for "factorial formula python"

10

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
5

factorial in python

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 November-23-2020
0

factorial in python

# Python code to demonstrate naive method
# to compute factorial
n = 23
fact = 1
  
for i in range(1,n+1):
    fact = fact * i
      
print ("The factorial of 23 is : ",end="")
print (fact)
Posted by: Guest on November-05-2021

Python Answers by Framework

Browse Popular Code Answers by Language