Check if a number is prime in Flipped Upside Down , Mirror Flipped and Mirror Flipped Upside Down | Function to check if N contains digits 0 , 1 , 2 , 5 , 8 only ; Extract digits of N ; Return false if any of these digits are present ; Function to check if N is prime or not ; Check for all factors ; Function to check if n is prime in all the desired forms ; Driver Code
function checkDigits ( n ) { do { var r = n % 10 ; if ( r == 3 r == 4 r == 6 r == 7 r == 9 ) return false ; n = parseInt ( n / 10 ) ; } while ( n != 0 ) ; return true ; } function isPrime ( n ) { if ( n <= 1 ) return false ; for ( var i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) return false ; } return true ; } function isAllPrime ( n ) { return isPrime ( n ) && checkDigits ( n ) ; } var N = 101 ; if ( isAllPrime ( N ) ) document . write ( " " ) ; else document . write ( " " ) ;