Store the unique primes
let cnt = new Array ( 1000009 ) ; for ( let i = 0 ; i < 1000001 ; i ++ ) cnt [ i ] = 0 ; let current_set = [ ] ; for ( let i = 0 ; i < current . length ; i ++ ) { cnt [ current [ i ] ] ++ ; if ( cnt [ current [ i ] ] == 1 ) current_set . push ( current [ i ] ) ; }