Count of N size strings consisting of at least one vowel and one consonant | Javascript program to count all possible Strings of length N consisting of atleast one vowel and one consonant ; Function to return base ^ exponent ; Function to count all possible Strings ; All possible Strings of length N ; Vowels only ; Consonants only ; Return the final result ; Driver code
var mod = parseInt ( 1e9 + 7 ) ; function expo ( base , exponent ) { var ans = 1 ; while ( exponent != 0 ) { if ( ( exponent & 1 ) == 1 ) { ans = ans * base ; ans = ans % mod ; } base = base * base ; base %= mod ; exponent >>= 1 ; } return ans % mod ; } function findCount ( N ) { var ans = ( expo ( 26 , N ) - expo ( 5 , N ) - expo ( 21 , N ) ) % mod ; ans += mod ; ans %= mod ; return ans ; } var N = 3 ; document . write ( findCount ( N ) ) ;