Traversing all numbers to find first pair
for ( var i = 2 ; i < n ; i ++ ) { var x = n / i ; if ( isPrime [ i ] && isPrime [ x ] && x != i && x * i == n ) { document . write ( i + " " + x ) ; flag = 1 ; return ; } } if ( flag == 0 ) document . write ( " " ) ; }