Create a boolean array " prime [ 0 . . N ] " and initialize all its entries as true . A value in prime [ i ] will finally be false if i is Not a prime , else true .
check = [ True for _ in range ( N + 1 ) ] NEW_LINE p = 2 NEW_LINE while p * p <= N : NEW_LINE