If the digit is a prime number , set the index of the digit to 1 in the bitmask .
if ( primeIndex . find ( digit ) != primeIndex . end ( ) ) { val += countOfNumbers ( index + 1 , mask | ( 1 << primeIndex [ digit ] ) , N ) ; } else { val += countOfNumbers ( index + 1 , mask , N ) ; } } }