find factorial of a number in python simple way

find factorial in python easy way only 5 lines

Coding Style = my style of coding

Coding language = python

def findFactorial(num):
    a = 1
    for x in range(0, num):
       a = a * (num -x)
    return a
print(findFactorial(5))

# 5! * 4! * 3! * 2! * 1!
# output : 
# 120

Explanation:
for x in range(0, 5)
Already set a = 1, so

First loop
=> a = 1 * (5 – 0)
=> a = 5

Second loop
=> a = 5 * (5 – 1)
=> a = 5 * 4
=> a = 20

Third loop
=> a = 20 * (5 – 2)
=> a = 20 * 3
=> a = 60

Fourth loop
=> a = 60 * (5 – 3)
=> a = 60 * 2
=> a = 120

Fourth loop
=> a = 120 * (5 – 4)
=> a = 120 * 1
=> a = 120
After that x range is now 4, we set only in the range between 0 to 5
Now loop ended. So we print( findFactorial(5) ) => its return answer 120.

Hope this logic will help you to understand the factorial concept in programming. Thank you for reading!