# Python 3 program to find
# factorial of given number
# Function to find factorial of given number
def factorial(n):
if n == 0:
return 1
return n * factorial(n-1)
# Driver Code
num = 5;
print("Factorial of", num, "is",
factorial(num))
# This code is contributed by Smitha Dinesh Semwal
import math
math.factorial(5) # Using math module
def factorial(n): # Doing it yourself
x = 1
for i in range(2,n+1):
x *= i
return x
def factorial(n):
fact = 1
for num in range(2, n + 1):
fact *= num
return fact
num = int(input("Enter a number to find factorial: "))
mul = 1
for x in range(1, num+1):
mul *= x
print("Factorial of", num, "=", mul)
# Python Program to find the factors of a number
# This function computes the factor of the argument passed
def print_factors(x):
print("The factors of",x,"are:")
for i in range(1, x + 1):
if x % i == 0:
print(i)
num = 320
print_factors(num)