Pair of integers ( a , b ) which satisfy the given equations | Function to count valid pairs ; Driver code
function pairCount ( n , m ) { var cnt = 0 , b , a ; for ( b = 0 ; b <= Math . sqrt ( m ) ; b ++ ) { a = m - b * b ; if ( a * a + b == n ) { cnt ++ ; } } return cnt ; } var n = 9 , m = 3 ; document . write ( pairCount ( n , m ) ) ;