Function to return the total number of M length words which have at least a single character repeated more than once
static int countWords ( int N , int M ) { return ( int ) Math . pow ( N , M ) - nPr ( N , M ) ; }