Published February 27, 2026|5 minute read
As part of a project, I needed to compute the probability of a large integer being B-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], where N≫L. Given that the integer N has no prime factors in an interval [B0,B1], what is the (conditional) probability that it is B-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<B.
Solution
Let K(a,b)⊆[a,b] denote the set of B-smooth integers in the interval [a,b]. Observe that the set of integers in K(a,b) divisible by a fixed prime p is in bijection with the set K(a/p,b/p).
By the principle of inclusion-exclusion (PIE), the number M of integers in K(N,N+L) which are not divisible by any p∈[B0,B1] isM=∣K(N,N+L)∣−B0≤p≤B1∑∣K(N/p,(N+L)/p)∣+B0≤p1<p2≤B1∑∣K(N/(p1p2),(N+L)/(p1p2))∣−⋯Recall that K(a,b)∼(b−a)ρ(ln(a)/ln(B)) for intervals with b−a≪a, where ρ is the Dickman-de Brujin function. We therefore haveLM∼ρ(lnN/lnB)−B0≤p≤B1∑ρ(lnBlnN−lnp)+B0≤p1<p2≤B1∑ρ(lnBlnN−lnp1−lnp2)−⋯Using the heuristic measure1primes∼xlnxdx∼uduwhere u:=lnx, we may writeLM∼ρ(lnN/lnB)−∫lnB0lnB1u1ρ(lnBlnN−u)du+2!1∫lnB0lnB1∫lnB0lnB1uv1ρ(lnBlnN−u−v)dudv−⋯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/lnB),
In(x):=n1∫lnB0lnB1uIn−1(x−u)du.Then we have the much nicer expressionP(clean and B-smooth):=LM=n=0∑∞(−1)nIn(lnN),where I have defined clean to be the property of having no prime factors in the interval [B0,B1], and smooth to mean B-smooth.
The functions In are easily computed iteratively over n, by keeping track of all values over the interval −1<x≤lnN. To obtain correct results, it is important to use the convention ρ(x)=0 for x<0 to remain consistent with the original formula from PIE.
Finally, we get the desired conditional probabilityP(B-smooth∣clean)=P(clean and ∞-smooth)P(clean and B-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), P(clean), and P(clean and B-smooth) for concrete values (B0,B1,B)=220,232,237.


Note that the slight wiggles in the purple curve are real and not numerical artifacts!
As N→∞, the probability P(clean) tends towards the value lnB0/lnB1. 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 B-smooth is lower than that of a generic integer.


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


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