if n is a perfect root , then both its square roots are its factors
if ( a * a == n ) { cout << " [ " << a << " , " << a << " ] " ; return ; } int b ; while ( true ) { int b1 = a * a - n ; b = ( int ) sqrt ( b1 ) ; if ( b * b == b1 ) break ; else a += 1 ; } cout << " [ " << ( a - b ) << " , " << ( a + b ) << " ] " ; return ; }