Program to calculate Permutation in Python



Program to calculate permutation in python:-

def fact(m):

    if(m==1 or m==0):

        return 1

    else:

        return (m*fact(int(m)-1))

n=int(input("enter value of n:"))

r=int(input("enter value of r:"))

if(n>=r and r>=0):

    print("Permutation=",int(fact(n)/fact(n-r)))

else:

    print("Invalid Input")


Code Screenshot and output:

    output:








Comments

Post a Comment

Popular posts from this blog

Program to print Z in Python

Hacker earth Binary subsequence "01" and "10" Problem Solution: