Find the count of M character words which have at least one character repeated | Function to return the factorial of a number ; Function to return the value of nPr ; Function to return the total number of M length words which have at least a single character repeated more than once ; Driver code
def fact ( n ) : NEW_LINE INDENT if ( n <= 1 ) : NEW_LINE INDENT return 1 ; NEW_LINE DEDENT return n * fact ( n - 1 ) ; NEW_LINE DEDENT def nPr ( n , r ) : NEW_LINE INDENT return fact ( n ) // fact ( n - r ) ; NEW_LINE DEDENT def countWords ( N , M ) : NEW_LINE INDENT return pow ( N , M ) - nPr ( N , M ) ; NEW_LINE DEDENT N = 10 ; M = 5 ; NEW_LINE print ( countWords ( N , M ) ) ; NEW_LINE