Answers for "factorial of a function 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
0

factorial python

def factorial(n)
    if n < 2:
        return 1
    else:
        return n * factorial(n - 1)
Posted by: Guest on October-23-2021
0

def factorial python

def factorial(n):            # Define a function and passing a parameter
        fact = 1                 # Declare a variable fact and set the initial value=1 
        for i in range(1,n+1,1): # Using loop for iteration
            fact = fact*i            
        print(fact)              # Print the value of fact(You can also use "return")

factorial(n) // Calling the function and passing the parameter
Posted by: Guest on March-21-2022

Code answers related to "factorial of a function python"

Python Answers by Framework

Browse Popular Code Answers by Language