Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

In Sieve of eratosthenes we have to first create an array of n elements to find all prime till n. What happen if n is very big (say 10^18) . Then this much memory may not available. So, how to solve such kind of problem using Sieve of eratosthenes.

You Can take boolean array of size n, that way you can simply mark the number using 1 bit

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.