A Python Program to Calculate Factorial Values Using Recursion

0

A Python Program to Calculate Factorial Values Using Recursion?

Source Code:

#Follow @Programmerfect

# recursive function to calculate factorial

def factorial(n):
   if n == 0:
      result = 1
   else:
      result = n*factorial(n-1)
   return result

#find factorial values for first 10 numbers

for i in range(1,11):
   print("Factorial of {} is {}".format(i, factorial(i)))


Post a Comment

0Comments
Post a Comment (0)