Find factors in Math . Sqrt ( x ) time
for ( int i = 2 ; i <= Math . Sqrt ( x ) ; i ++ ) { if ( x % i == 0 ) { fact . Add ( i ) ; if ( x / i != i ) fact . Add ( x / i ) ; factors . Add ( i ) ; factors . Add ( x / i ) ; } } bool found = false ; int k = fact . Count ; for ( int i = 0 ; i < k ; i ++ ) {