Find nPr Python

PROGRAM TO FIND nPr


import math
def fact(n): 
    if (n <= 1):
        return 1
          
    return n * fact(n - 1
  
def nPr(n, r): 
      
    return math.floor(fact(n) /
                fact(n - r)) 
      
# Driver code
n = 5
r = 2
  
print(n, "P", r, "=", nPr(n, r))


OUTPUT
5P2 = 20

Comments

Popular posts from this blog

Solve the Sudoku Python

Solve the Sudoku Java

Find Duplicates Java