Write a Python Program to Find the Factorial of a Number.

Write a Python Program to Find the Factorial of a Number.

Program
def myfun():
    num=int(input("Enter a number: "))
    factorial=1
    if(num<0):
        print("Factirial does not exist for negative numbers")
    elif(num==0):
        print("Factorial of 0 is 1")
    else:
        for i in range(1,num+1,1):
            factorial=factorial*i
        print("The factorial of ",num," is ",factorial)
              
if __name__=="__main__":
    myfun()



Output:

Enter a number: 1
The factorial of 1 is 1


Enter a number: 1
The factorial of 1 is 1


Enter a number: 5
The factorial of 5 is 120



More Questions


67 . Write a Python Program to Print all Prime Numbers in an Interval of 1-10.
68 . Write a Python Program to Find the Factorial of a Number.
69 . Write a Python Program to Display the multiplication Table.
70 . Write a Python Program to Print the Fibonacci sequence.
71 . Write a Python Program to Check Armstrong Number?
72 . Write a Python Program to Find Armstrong Number in an Interval.
73 . Write a Python Program to Find the Sum of Natural Numbers.
74 . Write a Python Program to Find LCM.
75 . Write a Python Program to Find HCF.
76 . Write a Python Program to Convert Decimal to Binary, Octal and Hexadecimal.
77 . Write a Python Program To Find ASCII value of a character.



For latest job updates join Telegram Channel: https://t.me/sateeshm