Search this website

Calculate factorial of a number in python

No comments
This is a simple function to calculate the factorial of any number  in python


def factorial(n):
    if n==1:
        return 1
    elif n==0:
        return 1
    else:
        fact=1
        for i in range(2,n+1):
            fact=fact*i
        return fact

No comments :

Post a Comment