text: Check if a number is prime in Flipped Upside Down , Mirror Flipped and Mirror Flipped Upside Down | C ++ program to implement the above approach ; 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
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; bool checkDigits ( int n ) { do { int r = n % 10 ; if ( r == 3 r == 4 r == 6 r == 7 r == 9 ) return false ; n /= 10 ; } while ( n != 0 ) ; return true ; } bool isPrime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) return false ; } return true ; } int isAllPrime ( int n ) { return isPrime ( n ) && checkDigits ( n ) ; } int main ( ) { int N = 101 ; if ( isAllPrime ( N ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }