If the digit is a prime number , set the index of the digit to 1 in the bitmask .
if ( primeIndex . has ( digit ) ) { let newMask = mask | ( 1 << primeIndex . get ( digit ) ) ; val += countOfNumbers ( index + 1 , newMask , N ) ; } else { val += countOfNumbers ( index + 1 , mask , N ) ; } } }