Python calcule factoriel
def factorial(n):
fact = 1
for num in range(2, n + 1):
fact = fact * num
return(fact)
Obedient Ox
def factorial(n):
fact = 1
for num in range(2, n + 1):
fact = fact * num
return(fact)
def fact(n):
return 1 if (n==0 or n==1) else n*fact(n-1)
fact(3)
import math
num = 5
print("The factorial of 5 is : ", end="")
print(math.factorial(num))
# output - The factorial of 5 is : 120
# The factorial of a number is the function that multiplies the number by every natural number below it
# e.g. - 1 * 2 * 3 * 4 * 5 = 120
def factorial(n):
fact = 1
for num in range(2, n + 1):
fact *= num
return fact