Python Lab 2a, 2b
Python Lab 2a, 2b
Read N
from the console.
PYTHON CODE
OUTPUT 1
PYTHON CODE
def fact(num):
if num == 0:
return 1
else:
return num * fact(num-1)
n = int(input("Enter the value of N : "))
r = int(input("Enter the value of R (R cannot be negative or greater than N): "))
nCr = fact(n)/(fact(r)*fact(n-r))
print(n,'C',r," = ","%d"%nCr,sep="")
OUTPUT 1
OUTPUT 2