Probability that a random number avoids a set of prime divisors

110 Views Asked by At

Let $P=\{p_1,\ldots, p_k\}$ be a set of primes. For a natural number $n$, define $\mu_P(n)$ as the probability that a random number selected from $\mathbb{N}_{\le n} = \{1,2,\ldots,n\}$ has no divisor among the primes in $P$. A few numerical examples: $$P = \{2,5,37\}, \; n = 1000, \; \mu_P(n) \approx 0.39\;.$$ $$P = \{3,7,11,19\}, \; n = 1000, \; \mu_P(n) \approx 0.49\;.$$ $$P = \{5,11,29,101\}, \; n = 1000, \; \mu_P(n) \approx 0.70\;.$$ $$P = \{5,11,29,101\}, \; n = 10000, \; \mu_P(n) \approx 0.49\;.$$

Q. For a given $P$ and $n$, how can $\mu_P(n)$ be calculated quickly?

My question is equivalent to calculating how much of $\mathbb{N}_{\le n}$ falls through the sieve determined by $P$, without explicitly listing that subset of $\mathbb{N}_{\le n}$ (that's what I mean by "quickly"). This is likely not a difficult calculation, but I am not getting it correct.

2

There are 2 best solutions below

2
On BEST ANSWER

An approximate answer, very accurate when $n$ is large compared to the primes, is $$\left(1-\frac 1{p_1}\right)\left(1-\frac 1{p_2}\right)\left(1-\frac 1{p_3}\right)\ldots\left(1-\frac 1{p_k}\right)$$ Basically each prime $p$ eliminates $\frac 1p$ of the values. The eliminations are almost independent, so you just multiply them. It will be exact when $n$ is a multiple of the product of the primes.

0
On

This probability $\mu_{P}(n)$ can be expressed by an explicit formula.

Indeed, we have $$\mu_{P}(n) = \frac{\left|\cap_{i = 1}^{k} \left(\left\{1, ..., n\right\} \backslash X_{i}\right)\right|}{n} = 1 -\frac{\left|\cup_{i = 1}^{k} X_{i}\right|}{n}$$ where for all $i \in \left\{1, ..., k\right\}$, $X_{i}$ denotes the set of integers in $\left\{1, ..., n\right\}$ which are multiples of $p_{i}$.
Now, by the inclusion-exclusion principle, we have $$\left|\cup_{i = 1}^{k} X_{i}\right| = \sum_{j = 1}^{k} (-1)^{j +1} \sum_{1 \leq i_{1} < ... < i_{j} \leq k} \left|X_{i_{1}} \cap ... \cap X_{i_{j}}\right| = \sum_{j = 1}^{k} (-1)^{j +1} \sum_{1 \leq i_{1} < ... < i_{j} \leq k} \Big\lfloor{\frac{n}{p_{i_{1}} ... p_{i_{j}}}}\Big\rfloor$$ Thus, we get $$\mu_{P}(n) = 1 -\frac{\sum_{j = 1}^{k} (-1)^{j +1} \sum_{1 \leq i_{1} < ... < i_{j} \leq k} \Big\lfloor{\frac{n}{p_{i_{1}} ... p_{i_{j}}}}\Big\rfloor}{n}$$
But I am not quite sure if my answer respects your "quickly" requirement...

P.S: Note that if $n$ is a multiple of $p_{1} ... p_{k}$, then we have - by Vieta's formulas - $$\mu_{P}(n) = 1 -\frac{\sum_{j = 1}^{k} (-1)^{j +1} \sum_{1 \leq i_{1} < ... < i_{j} \leq k} {\frac{n}{p_{i_{1}} ... p_{i_{j}}}}}{n} = \left(1 -\frac{1}{p_{1}}\right) ... \left(1 -\frac{1}{p_{k}}\right)$$ as stated by Ross Millikan.