text: Check if given number is Emirp Number or not | Returns true if n is prime else false ; Corner case ; Check from 2 to n - 1 ; Function will check whether number is Emirp or not ; Check if n is prime ; Find reverse of n ; If both Original and Reverse are Prime , then it is an Emirp number ; Input number
code: < ? php function isPrime ( $ n ) { if ( $ n <= 1 ) return -1 ; for ( $ i = 2 ; $ i < $ n ; $ i ++ ) if ( $ n % $ i == 0 ) return -1 ; return 1 ; } function isEmirp ( $ n ) { if ( isPrime ( $ n ) == -1 ) return -1 ; $ rev = 0 ; while ( $ n != 0 ) { $ d = $ n % 10 ; $ rev = $ rev * 10 + $ d ; $ n /= 10 ; } return isPrime ( $ rev ) ; } $ n = 13 ; if ( isEmirp ( $ n ) == -1 ) echo " Yes " ; else echo " No " ; ? >