Mark multiples of prime [ i ] in [ low . . high ] : We are marking j - low for j , i . e . each number in range [ low , high ] is mapped to [ 0 , high - low ] so if range is [ 50 , 100 ] marking 50 corresponds to marking 0 , marking 51 corresponds to 1 and so on . In this way we need to allocate space only for range
for ( int j = loLim ; j < high ; j += prime [ i ] ) mark [ j - low ] = false ; }