Python function to calculate the factorial of a number. The function accepts he number as an argument.

Code:

def fact(num):

    factorial = 1;

    for i in range(1, num+1):

        factorial = factorial * i

    print("Factorial of", i, "is:", factorial)

x = int(input("Enter a number: "))

fact(x)

Output:

Comments

Popular posts from this blog

State use of pep and pip