Pair of integers ( a , b ) which satisfy the given equations | C # program to count the pair of integers ( a , b ) which satisfy the equation a ^ 2 + b = n and a + b ^ 2 = m ; Function to count valid pairs ; Driver code
using System ; class GFG { static int pairCount ( int n , int m ) { int cnt = 0 , b , a ; for ( b = 0 ; b <= Math . Sqrt ( m ) ; b ++ ) { a = m - b * b ; if ( a * a + b == n ) { cnt ++ ; } } return cnt ; } public static void Main ( String [ ] args ) { int n = 9 , m = 3 ; Console . Write ( pairCount ( n , m ) + " STRNEWLINE " ) ; } }