4

If I want to calculate all the primes, could I do this? Let $N = \{2,3,4,5,6,7,8,..\}$ Then the elements in $N - NN$ are prime? Because they are the ones that aren't composite?

Sloan
  • 2,303

2 Answers2

4

Yes, that is correct.

If $m$ is a composite, then it can be written as $n\cdot k$ for some $2\leq n,k<m$, which means that $m\in NN$.

If $m$ is a prime number, then it cannot be written as such product, so it is not in $NN$. Therefore $N-NN$ is exactly the prime numbers.

Asaf Karagila
  • 393,674
2

Essentially, yes. You may struggle to compute $N-NN$, but that set would contain the primes and only the primes.

If you want to actually calculate prime numbers, a good way would be to use the Sieve of Eratosthenes (the animation uses $n=10$). The idea is you start with a list of primes up to some number $n$, and then consider the integers up to $n^{2}$. Every composite number in this interval must have at least one prime factor at most as large as $n$, so if you eliminate all the multiples of primes up to $n$, you have all the primes up to $n^{2}$.