Check n ^ 2 | Check if a number is prime or not ; Run a loop upto square of given number ; Check if n ^ 2 - m ^ 2 is prime ; Driver Code
function isprime ( x ) { for ( var i = 2 ; i * i <= x ; i ++ ) if ( x % i == 0 ) return false ; return true ; } function isNSqMinusnMSqPrime ( m , n ) { if ( n - m == 1 && isprime ( m + n ) ) return true ; else return false ; } var m = 13 , n = 16 ; if ( isNSqMinusnMSqPrime ( m , n ) ) document . write ( " " ) ; else document . write ( " " ) ;