To find ncR and nPr in python, you have to ask from user to enter the value of n and r and then find the value of ncR and nPr to print the result on output screen as shown in the given program.
Following python program ask from user to enter the value of n and r to find and print the value of ncR and nPr:
# Python Program - Find ncR and nPr import math while True: print("Enter 'x' for exit.") nval = input("Enter value of n: ") rval = input("Enter value of r: ") if nval == 'x': break else: n = int(nval) r = int(rval) npr = math.factorial(n)/math.factorial(n-r) ncr = npr/math.factorial(r) print("ncR =",ncr) print("nPr =",npr) print("\n")
Here is the sample run of the above Python program shows how to find ncR and nPr:
You may also like to learn or practice the same program in other popular programming languages: