Update all multiples of p greater than or equal to the square of it numbers which are multiples of p and are less than p ^ 2 are already marked .
for i in range ( p * p , N + 1 , p ) : NEW_LINE INDENT check [ i ] = False NEW_LINE DEDENT p += 1 NEW_LINE