Essentially we have two ways to solve this problem:

 

  • ATesting in order one by one if the number is prime or not. And if it is write it.

 

WHAT IS MORE CONVENIENT?

    • Choice A

Disadvantages: We have to calculate if the number is prime or not for each number.
Advantages: We don’t need store the numbers.

    • Choice B

Disadvantages: We need store all numbers (although We can drastically reduce)
Advantages: It’s more faster because the primes are not calculated.

We Choose option B because it is much easier store than process and also can greatly reduce the numbers we store considering that we can eliminate half of the numbers if we eliminate the even numbers in the list, and a third if we eliminate multiples of 3 and so on, while we can keep indexing properly.

Share this!
Share on Facebook0Share on Tumblr0Tweet about this on TwitterShare on Reddit0Share on StumbleUpon0Share on Google+0Email this to someone