Count of distinct permutations of every possible length of given string | Function to find the factorial of a number ; Loop to find the factorial of the given number ; Function to find the number of permutations possible for a given string ; Function to find the total number of combinations possible ; Driver Code
def fact ( a ) : NEW_LINE INDENT f = 1 NEW_LINE for i in range ( 2 , a + 1 ) : NEW_LINE INDENT f = f * i NEW_LINE DEDENT return f NEW_LINE DEDENT def permute ( n , r ) : NEW_LINE INDENT ans = 0 NEW_LINE ans = fact ( n ) // fact ( n - r ) NEW_LINE return ans NEW_LINE DEDENT def findPermutations ( n ) : NEW_LINE INDENT sum = 0 NEW_LINE for r in range ( 1 , n + 1 ) : NEW_LINE INDENT P = permute ( n , r ) NEW_LINE sum = sum + P NEW_LINE DEDENT return sum NEW_LINE DEDENT str = " xz " NEW_LINE n = len ( str ) NEW_LINE print ( findPermutations ( n ) ) NEW_LINE