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