Showing posts with label python factorial. Show all posts
Showing posts with label python factorial. Show all posts

Thursday, 24 February 2022

FACTORIAL OF A GIVEN NUMBER

 FACTORIAL OF A GIVEN NUMBER

def factorial(n):

   if n == 1:

       return n

   else:

       return n*factorial(n-1)


num = 8


if num == 0:

   print("The factorial = 1")

else:

   print("The factorial = ",factorial(num))

OUTPUT: