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