Check n ^ 2 | Check a number is prime or not ; run a loop upto square of given number ; Check if n ^ 2 - m ^ 2 is prime ; Driver code
< ? php function isprime ( $ x ) { for ( $ i = 2 ; $ i * $ i <= $ x ; $ i ++ ) if ( $ x % i == 0 ) return false ; return true ; } function isNSqMinusnMSqPrime ( $ m , $ n ) { if ( $ n - $ m == 1 and isprime ( $ m + $ n ) ) return true ; else return false ; } $ m = 13 ; $ n = 16 ; if ( isNSqMinusnMSqPrime ( $ m , $ n ) ) echo " YES " ; else echo " NO " ; ? >