factorial()
« All Math methods
factorial is the product of all the positive integers less than or equal to input number.
!n is also denoted as factorial of a number .
import math
print(math.factorial(4)) # 24
factorial of 4 is 24.
import math
print(math.factorial(12)) # 479001600
Factorial of a number without using the factorial() function
n=12
factorial=1
for i in range (1,n+1):
factorial=factorial * i
print(factorial)
Output is here
479001600
Factorial of a Number »
Practice Questions
Find the factorial of an input number. check the number before using factorial() method.
Check your answer without importing math module.
import math
x=input("Enter the number : ")
if x.isdigit():
print(math.factorial(int(x)))
else:
print(" Enter correct number ")
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com