0

I am doing some tutorials on programming, and I am on the classic "write a program that returns true if and only if the input is a prime number". The solution is straightforward: for every number $d$ between $2$ and $N-1$ test if $d$ is a divisor of $N$.

The first optimization is to reduce the testing interval to $[2, \sqrt{N}]$.

The next optimization is to reduce the testing interval by eliminating the even numbers in it (plus a particular test for 2).

Now becomes the next optimizations: what if I eliminate the multiples of 3 too? With the due adjustings, it reduces the interval to 1/3 of its original size. (It is just Inclusion-Exclusion from Combinatorics.)

We can do this further for the next primes. Summing up, after $k$ interactions the set is reduced to $\prod_{1 \leq i \leq k}\left( 1-\frac{1}{p_i} \right)$ of its original size.

Therefore, my question is:

What is the $\lim_{n \rightarrow \infty} \prod_{1 \leq i \leq n}\left( 1-\frac{1}{p_i} \right)$?

Probably the limit has no known "closed form", but it would be cool to know it to at least some decimal places. After all, it can be useful to establish a point when the optimization efforts supersede the gains.

Bernard
  • 179,256
Anderson Torres
  • 306
  • 1
  • 11

0 Answers0