Published February 27, 2026|5 minute read

As part of a project, I needed to compute the probability of a large integer being BB-smooth, conditional on knowledge about the sizes of its prime factors. I found very little information about this problem in the literature.

This post (1) solves this problem with high accuracy, and (2) verifies the theoretical results experimentally.

Problem Statement

Choose an integer uniformly at random from the interval [N,N+L][N, N + L], where N≫LN \gg L. Given that the integer NN has no prime factors in an interval [B0,B1][B_0, B_1], what is the (conditional) probability that it is BB-smooth?

This problem can be easily extended to e.g. restrict prime factors to multiple subintervals. For simplicity, we will analyze the single-interval problem above. In what follows, we assume that B0<B1<BB_0 < B_1 < B.

Solution

Let K(a,b)⊆[a,b]K(a, b) \subseteq [a, b] denote the set of BB-smooth integers in the interval [a,b][a, b]. Observe that the set of integers in K(a,b)K(a, b) divisible by a fixed prime pp is in bijection with the set K(a/p,b/p)K(a/p, b/p).

By the principle of inclusion-exclusion (PIE), the number MM of integers in K(N,N+L)K(N, N+L) which are not divisible by any p∈[B0,B1]p \in [B_0, B_1] isM= ∣K(N,N+L)∣−∑B0≤p≤B1∣K(N/p,(N+L)/p)∣+∑B0≤p1<p2≤B1∣K(N/(p1p2),(N+L)/(p1p2))∣−⋯ \begin{aligned} M = \, &|K(N, N+L)| \\ &- \sum_{B_0 \leq p \leq B_1} |K(N/p, (N+L)/p)| \\ &+ \sum_{B_0 \leq p_1 < p_2 \leq B_1} |K(N/(p_1 p_2), (N+L)/(p_1 p_2))| \\ &- \cdots \end{aligned} Recall that K(a,b)∼(b−a) ρ(ln⁡(a)/ln⁡(B))K(a, b) \sim (b-a) \, \rho(\ln(a)/\ln(B)) for intervals with b−a≪ab-a \ll a, where ρ\rho is the Dickman-de Brujin function. We therefore haveML∼ ρ(ln⁡N/ln⁡B)−∑B0≤p≤B1ρ(ln⁡N−ln⁡pln⁡B)+∑B0≤p1<p2≤B1ρ(ln⁡N−ln⁡p1−ln⁡p2ln⁡B)−⋯ \begin{aligned} \frac{M}{L} \sim \, &\rho(\ln{N}/\ln{B}) \\ &- \sum_{B_0 \leq p \leq B_1} \rho\left(\frac{\ln{N} - \ln{p}}{\ln{B}}\right) \\ &+ \sum_{B_0 \leq p_1 < p_2 \leq B_1} \rho\left(\frac{\ln{N} - \ln{p_1} - \ln{p_2}}{\ln{B}}\right) \\ &- \cdots \end{aligned} Using the heuristic measure1primes∼dxxln⁡x∼duu\mathbb{1}_{\text{primes}} \sim \frac{dx}{x \ln{x}} \sim \frac{du}{u}where u:=ln⁡xu := \ln{x}, we may writeML∼ ρ(ln⁡N/ln⁡B)−∫ln⁡B0ln⁡B11u ρ(ln⁡N−uln⁡B)du+12!∫ln⁡B0ln⁡B1∫ln⁡B0ln⁡B11uv ρ(ln⁡N−u−vln⁡B)dudv−⋯ \begin{aligned} \frac{M}{L} \sim \, &\rho(\ln{N}/\ln{B}) \\ &- \int_{\ln{B_0}}^{\ln{B_1}} \frac{1}{u} \, \rho\left(\frac{\ln{N} - u}{\ln{B}}\right) \dd{u} \\ &+ \frac{1}{2!} \int_{\ln{B_0}}^{\ln{B_1}} \int_{\ln{B_0}}^{\ln{B_1}} \frac{1}{uv} \, \rho\left(\frac{\ln{N} - u - v}{\ln{B}}\right) \dd{u} \dd{v} \\ &- \cdots \end{aligned} This is a bit unwieldy, and the multidimensional integrals are difficult to compute numerically. Luckily, it's possible to simplify this quite a bit.

Simplification

Recursively define the helper functionI0(x):=ρ(x/ln⁡B), I_0(x) := \rho(x/\ln{B}), In(x):=1n∫ln⁡B0ln⁡B1In−1(x−u)u du. I_n(x) := \frac{1}{n} \int_{\ln{B_0}}^{\ln{B_1}} \frac{I_{n-1}(x-u)}{u} \, \dd{u}. Then we have the much nicer expressionP(clean and B-smooth):=ML=∑n=0∞(−1)n In(ln⁡N), \mathbb{P}(\text{clean and }B\text{-smooth}) := \frac{M}{L} = \sum_{n=0}^\infty (-1)^n \, I_n(\ln{N}), where I have defined clean to be the property of having no prime factors in the interval [B0,B1][B_0, B_1], and smooth to mean BB-smooth.

The functions InI_n are easily computed iteratively over nn, by keeping track of all values over the interval −1<x≤ln⁡N-1 < x \leq \ln{N}. To obtain correct results, it is important to use the convention ρ(x)=0\rho(x) = 0 for x<0x < 0 to remain consistent with the original formula from PIE.

Finally, we get the desired conditional probabilityP(B-smooth ∣ clean)=P(clean and B-smooth)P(clean and ∞-smooth), \mathbb{P}(B\text{-smooth} \, | \, \text{clean}) = \frac{\mathbb{P}(\text{clean and }B\text{-smooth})}{\mathbb{P}(\text{clean and }\infty\text{-smooth})}, where both the numerator and denominator can be computed using the formula above.[1]

Numerical Computation

The below plot shows the quantities P(B-smooth)\mathbb{P}(B\text{-smooth}), P(clean)\mathbb{P}(\text{clean}), and P(clean and B-smooth)\mathbb{P}(\text{clean and }B\text{-smooth}) for concrete values (B0,B1,B)=220,232,237(B_0, B_1, B) = 2^{20}, 2^{32}, 2^{37}.

Graph showing probabilities of being B-smooth and/or clean as a function of log(N).Graph showing probabilities of being B-smooth and/or clean as a function of log(N).

Note that the slight wiggles in the purple curve are real and not numerical artifacts!

As N→∞N \to \infty, the probability P(clean)\mathbb{P}(\text{clean}) tends towards the value ln⁡B0/ln⁡B1\ln{B_0}/\ln{B_1}. This is consistent with Mertens’ third theorem.

From the above curves, we can also compute the conditional probability of interest. As expected, the probability of a clean integer being BB-smooth is lower than that of a generic integer.

Graph showing conditional probability of being B-smooth given clean as a function of log(N).Graph showing conditional probability of being B-smooth given clean as a function of log(N).

Finally, we can experimentally generate clean integers[2] and plot the probability of being BB-smooth for various values of BB, and compare against the theoretical reference.

Experimental results agree very well with theoretical prediction.Experimental results agree very well with theoretical prediction.

We get excellent agreement, even down to the subtle wiggles in the theoretical prediction.


Footnotes

  1. [1]Note that all integers are ∞\infty-smooth.↩
  2. [2]This can be done efficiently using a sieve over primes p∈[B0,B1]p \in [B_0, B_1] and removing the sieved part. The remaining cofactors are all clean values of NN.↩