Python Factorial
def factorial(n):
fact = 1
for num in range(2, n + 1):
fact *= num
return fact
Rich Rat
def factorial(n):
fact = 1
for num in range(2, n + 1):
fact *= num
return fact
def factors(n):
return set(reduce(list.__add__, \
([i, n//i] for i in range(1, int(n**0.5) + 1) if not n % i )))
# 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)