Visit codepro.blog 🌐 for complete code examples 💻, additional articles 📚, and more resources 🚀. "Like , Share and Subscribe " #FactorialNumber
---------------------------------------------------------------------------------------------------------------------
Python is a simple, general purpose, high level, and object-oriented programming language.
Python is an interpreted scripting language also. Guido Van Rossum is known as the founder of Python programming.
-------------------------------------------------------------------------------------------------------------------
Python Program to Find the Factorial of a Number
code :
num = int(input("Enter a number: "))
factorial = 1
if num - 0: replace ( - ) by angle brackets
print(" Factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i
print("The factorial of",num,"is",factorial)
----------------------------------------------------------------------------------------------------------------
Using built-in function :
code:
import math
def fact(n):
return(math.factorial(n))
num = int(input("Enter the number:"))
f = fact(num)
print("Factorial of", num, "is", f)
-------------------------------------------------------------------------------------------------------------
Pythonprogramtofind
factorialofgivennumber