Set all multiples of p as non - prime
for ( let i = p * p ; i < 100001 ; i += p ) prime [ i ] = 0 ; } p += 1 ; } } function join ( a , b ) { let mul = 1 ; let bb = b ; while ( b != 0 ) { mul *= 10 ; b = parseInt ( b / 10 , 10 ) ; } a *= mul ; a += bb ; return a ; }