filmov
tv
12. Programming using Python - Functions and recursion by Sunil Sir

Показать описание
Functions
1. Functions and Recursion
2. Recursion Example
PYTHON CODE:
#function to find factorial of a numbers
def factorial (n):
print("Call to factorial(",n,") copy")
if(n == 1):
fact = 1
else:
fact= n * factorial(n-1)
print("Back to Copy ",n+1)
return fact
#Driver Code
num = 4
result=factorial(num)
print(“Factorial of “,num,” is :”,result)
1. Functions and Recursion
2. Recursion Example
PYTHON CODE:
#function to find factorial of a numbers
def factorial (n):
print("Call to factorial(",n,") copy")
if(n == 1):
fact = 1
else:
fact= n * factorial(n-1)
print("Back to Copy ",n+1)
return fact
#Driver Code
num = 4
result=factorial(num)
print(“Factorial of “,num,” is :”,result)