Number

The largest prime in a typical number

Count a number's prime factors and the answer is about log log n. Ask instead how big the largest one is, and the answer is a power of n with a law of its own: half of all large numbers have a prime factor above n^0.6065, and the share whose primes all stay below n^(1/u) is Dickman's ρ(u), a function defined by its own past. The same law governs the longest cycle of a random shuffle, and there it arrives at once; for the numbers themselves, at ten million, it is still visibly on its way.

Worth reading first: How many primes a typical number has · The same bell on thinner sets.

How many primes a typical number has counted. A number near NN has about log⁡log⁡N\log \log N different prime factors, spread around that in a bell curve whose variance is log⁡log⁡N\log \log N as well, and the same bell on thinner sets found the same count, slightly shifted, on the numbers one less than a prime and on the squares plus one. Both essays treated the prime factors as a list to be counted, each small prime dividing independently with probability one over itself, like a coin. That picture said nothing about how large the factors are, and it could not, because for the count the large primes hardly matter: a number can have at most one prime factor above its own square root.

But the large primes are where most of a number’s size is. Of the digits of a typical number near a million, more than half belong to its largest prime factor. The question this essay measures is how large that factor is — not in absolute terms, which grow with the number, but as a power of it. The answer is a law, found by Karl Dickman in 1930, governed by a function that is defined by its own past and has no closed form beyond its first piece. It also governs, exactly and by a different route, the longest cycle of a shuffled pack of cards.

The largest prime factor, as a power of the number. Share of n with log P(n)/log n ≤ s: at s=0.5, n≤10⁴ 0.268, n≤10⁷ 0.272, Dickman 0.307; median e^(−1/2) = 0.6065; largest gap at 10⁷ 0.061.
Fig. 1 For every nn up to 10410^4 and up to 10710^7, the size of its largest prime factor PP as a power of nn, s=log⁡P/log⁡ns = \log P / \log n, and the share of nn whose ss is at most each value. The dark curve is Dickman’s limit, in which that share is ρ(1/s)\rho(1/s). Half of all large numbers have a prime factor bigger than n0.6065n^{0.6065}. The counted curves lie below the limit and close in on it slowly.

A number’s largest prime, measured as a power

Write P(n)P(n) for the largest prime dividing nn. For a prime, P(n)=nP(n) = n; for a power of two, P(n)=2P(n) = 2. The ratio s=log⁡P(n)/log⁡ns = \log P(n) / \log n puts every number on the same scale: s=1s = 1 for primes, s=1/2s = 1/2 for the square of a prime and for a number whose largest prime is about its square root, and ss near zero for numbers built entirely from small primes. The hero figure computes P(n)P(n) for every nn up to ten million — by a sieve that walks through the multiples of each prime in increasing order and writes the prime into each, so that the last prime written is the largest — and plots the share of numbers whose ss is at most each value.

The curve has a shape that the counting essays gave no hint of. Almost no number has ss below 0.20.2: a number whose prime factors are all below its fifth root is rare. Among the numbers up to ten million, a fifth have ss below 0.470.47, a quarter below about 0.490.49, and half below about 0.630.63. Above that the curve climbs steadily to the right-hand edge, where it jumps: the jump is the primes, every one of which has s=1s = 1, and there are about n/log⁡nn / \log n of them, a share that shrinks as the range grows. Dickman’s theorem says that this curve has a limit. As the range grows, the share of nn with s≤ts \le t tends to ρ(1/t)\rho(1/t), where ρ\rho is a function he defined for the purpose, and the median of the limit is exactly e−1/2=0.6065e^{-1/2} = 0.6065: half of all large numbers have a prime factor larger than n0.6065n^{0.6065}.

The counted curves lie below the limit, and the gap is closing. At ten thousand the largest gap is about twelve percentage points; at ten million it is about six. The direction of the gap means that at these sizes the largest prime factor is a slightly bigger power of the number than the limit allows — a small-number effect that the second figure below and the fourth will trace.

A function defined by its own past

The heuristic behind Dickman’s function is a self-similarity. Suppose a number nn has its largest prime pp of size about n1/vn^{1/v} for some vv. Then n=p⋅mn = p \cdot m, where mm is about n1−1/vn^{1 - 1/v}, and mm’s own prime factors are all at most pp. Asking for the share of nn whose primes are all below n1/un^{1/u} thus turns into an average, over the possible sizes of the largest prime, of the same question asked about a smaller number with a smaller exponent. Written as a calculus statement, the share ρ(u)\rho(u) of numbers whose prime factors are all at most n1/un^{1/u} satisfies

u ρ′(u)=−ρ(u−1),ρ(u)=1 for 0≤u≤1.u \, \rho'(u) = -\rho(u - 1), \qquad \rho(u) = 1 \text{ for } 0 \le u \le 1.

The equation is a delay differential equation: the slope at uu depends on the value one unit back.

A function defined by its own past. ρ(u) for u in [0, 5]: ρ(1.5) = 0.59453, ρ(2) = 0.306853, ρ(3) = 0.048608, ρ(4) = 4.91093e-3, ρ(5) = 3.54725e-4.
Fig. 2 Dickman’s function: ρ(u)=1\rho(u) = 1 for uu up to 1, and beyond that u ρ′(u)=−ρ(u−1)u\,\rho'(u) = -\rho(u-1). On [1,2][1, 2] it is exactly 1−log⁡u1 - \log u; after that each piece is an integral of the last. It falls from 0.3070.307 at 2 to 0.04860.0486 at 3, 4.91×10−34.91 \times 10^{-3} at 4 and 3.55×10−43.55 \times 10^{-4} at 5.

The first piece can be found by hand. For uu between 1 and 2, the value one unit back is 1, so uρ′(u)=−1u\rho'(u) = -1, and ρ(u)=1−log⁡u\rho(u) = 1 - \log u. At u=2u = 2 this gives ρ(2)=1−log⁡2=0.3069\rho(2) = 1 - \log 2 = 0.3069: the share of numbers with no prime factor above their square root is about 31 per cent, and so the share with one prime factor above its square root — there can be only one — is about 69 per cent. On the next interval the value one unit back is 1−log⁡(u−1)1 - \log(u - 1), and the integral that results involves the dilogarithm; after that the pieces are new functions each time, and nothing simpler than the equation itself describes them. The figure computes ρ\rho by integrating the equation one unit interval at a time, using the interval before as known input. The one care needed is at the integers, where each derivative in turn has a kink: a numerical rule that averages across a kink loses accuracy there, and a first attempt that did so drifted by a few parts in a billion — invisible on this figure, and a factor of a hundred on the logarithmic scale of the last one. Restarting the rule at every integer removes the drift.

Smooth numbers, and how slowly the limit arrives

A number whose prime factors are all at most yy is called yy-smooth, and the count of yy-smooth numbers up to xx is written Ψ(x,y)\Psi(x, y). Dickman’s theorem in this form says that for every fixed uu,

Ψ(x,x1/u)∼x ρ(u)as x→∞.\Psi\bigl(x, x^{1/u}\bigr) \sim x\,\rho(u) \qquad \text{as } x \to \infty.

This is a statement about a fixed bound x1/ux^{1/u} for all numbers up to xx, rather than a bound that moves with each nn as in the hero figure, and it is the form used everywhere smooth numbers matter.

Smooth numbers outnumber the limit, and the limit wins slowly. u=2: 1e+3 434 (×1.414), 1e+4 3716 (×1.211), 1e+5 35819 (×1.167), 1e+6 344299 (×1.122), 1e+7 3362157 (×1.096); u=3: 1e+3 141 (×2.901), 1e+4 1169 (×2.405), 1e+5 8740 (×1.798), 1e+6 72271 (×1.487), 1e+7 665196 (×1.368); u=4: 1e+3 86 (×17.512), 1e+4 338 (×6.883), 1e+5 2579 (×5.252), 1e+6 18083 (×3.682), 1e+7 115696 (×2.356); u=5: 1e+3 40 (×112.764), 1e+4 175 (×49.334), 1e+5 694 (×19.564), 1e+6 4106 (×11.575), 1e+7 28434 (×8.016).
Fig. 3 The number of n≤xn \le x whose prime factors are all at most x1/ux^{1/u}, divided by Dickman’s prediction xρ(u)x\rho(u), for u=2u = 2 to 55 and xx from 10310^3 to 10710^7. Every ratio falls towards 1 at every step, but slowly, and more slowly the larger uu: at 10710^7 the square-root-smooth numbers are 1.101.10 times the prediction, and the numbers with no prime above 25.125.1 are 8.08.0 times it.

The counts confirm the theorem’s direction and expose its pace. Every ratio is above 1 and falls at every tenfold step, as it must if it is to reach 1. For u=2u = 2 it has nearly arrived: there are 3,362,157 numbers up to ten million with no prime factor above 107≈3,162\sqrt{10^7} \approx 3{,}162, against a prediction of 3,068,528, ten per cent more. For u=5u = 5 it has barely started. The bound is then 107/5≈25.110^{7/5} \approx 25.1, so the count is of numbers built entirely from the nine primes up to 23, and there are 28,434 of them against a prediction of 3,547. Dickman’s theorem fixes uu and lets xx grow, so the bound x1/ux^{1/u} grows too, and the limit describes numbers whose smoothness bound is itself large. At ten million and u=5u = 5 the bound is 25, and a set of nine primes is nothing like the limiting picture of primes thick enough to be treated as a continuum.

The correction is known in principle — Nicolaas de Bruijn gave an asymptotic expansion in 1951, and Adolf Hildebrand determined in 1986 how small yy can be, relative to xx, for the approximation by ρ\rho to remain good — but the practical lesson of the figure is simpler. The approximation is good when the smoothness bound has many primes below it and poor when it has few, and at the sizes anyone can count, “few” covers most of the interesting range.

The average largest prime

Integrating Dickman’s law gives the average of s=log⁡P/log⁡ns = \log P / \log n over all large numbers:

λ=∫01(1−ρ(1/t)) dt=0.62433…\lambda = \int_0^1 \bigl(1 - \rho(1/t)\bigr)\, dt = 0.62433\ldots

This is the Golomb–Dickman constant. On average, the largest prime factor of a large number accounts for about 62 per cent of its digits.

The average largest prime closes in like one over log x. 1e+3: mean 0.6572, median 0.650; 1e+4: mean 0.6551, median 0.645; 1e+5: mean 0.6524, median 0.640; 1e+6: mean 0.6494, median 0.635; 1e+7: mean 0.6466, median 0.630; limits 0.624330 and 0.606531.
Fig. 4 For every nn up to xx, the mean of s=log⁡P/log⁡ns = \log P / \log n and its median, for xx from 10310^3 to 10710^7, with the limits dashed. The mean falls from 0.65720.6572 to 0.64660.6466 towards 0.624330.62433; the median sits above e−1/2e^{-1/2}. The mean’s excess multiplied by log⁡x\log x reads 0.230.23, 0.280.28, 0.320.32, 0.350.35, 0.360.36, levelling off.

The counted mean is 0.65720.6572 for numbers up to a thousand and 0.64660.6466 for numbers up to ten million — still two and a quarter hundredths above the limit, after multiplying the range by ten thousand. The median, read to the nearest half-hundredth, falls from 0.6500.650 to 0.6300.630 against 0.60650.6065. The pace is the same slow pace as for the smooth counts, and the figure measures it. It is far slower than the pace at which the bell arrives for a sum of independent terms, where the error falls like one over the square root of the number of terms; here the number of terms is in effect log⁡x\log x, and the error falls like its reciprocal. If the excess of the mean over λ\lambda were shrinking like a constant divided by log⁡x\log x, then multiplying it by log⁡x\log x would give a sequence levelling off at that constant; the products are 0.230.23, 0.280.28, 0.320.32, 0.350.35 and 0.360.36, rising more slowly at each step. The excess at ten million is about 0.36/log⁡x0.36/\log x, and if the constant settles near 0.40.4, closing the excess to one hundredth would take xx of about 101710^{17}.

That rate has a plain cause. The smallest primes, 2 and 3 and 5, are fixed while log⁡x\log x grows, and they are the ones whose contribution to log⁡n\log n the limit treats as negligible. A number up to a thousand that is 2×2 \times a prime has ss close to 0.9, and there are many of them; in the limit, the factor 2 is a vanishing part of log⁡n\log n, and ss for such numbers tends to 1 — but also, in the limit, almost no number is twice a prime. The finite ranges carry the memory of their small primes in every statistic, and that memory fades like 1/log⁡x1/\log x.

A shuffle obeys the same law, and obeys it sooner

Solomon Golomb met the constant 0.624330.62433 in 1964 in a problem that has nothing to do with primes: the longest cycle of a random permutation. Shuffle nn cards, follow where the card in position 1 goes, then where that card’s position goes, and so on until the path returns to position 1; that is a cycle, and the shuffle breaks the cards into cycles. Golomb asked for the expected length of the longest one, as a fraction of nn, and found it tends to 0.624330.62433. Lawrence Shepp and Stuart Lloyd showed in 1966 that the whole distribution of the longest cycle’s share tends to Dickman’s law, and later work showed that the agreement is complete: the sizes of all the cycles, as fractions of nn, and the sizes of all the prime factors, as fractions of log⁡n\log n, follow the same limiting law, the Poisson–Dirichlet distribution.

A shuffle's longest cycle follows the same law. n=10: P(longest ≤ n/2) = 0.3544; n=30: P(longest ≤ n/2) = 0.3232; n=100: P(longest ≤ n/2) = 0.3118; Dickman ρ(2) = 0.3069.
Fig. 5 The chance that a random shuffle of nn objects has no cycle longer than s⋅ns \cdot n, computed exactly, for n=10n = 10, 3030 and 100100, against the curve ρ(1/s)\rho(1/s). At n=100n = 100 the chance that no cycle is longer than half is 0.31180.3118 against 1−log⁡2=0.30691 - \log 2 = 0.3069.

For shuffles the law can be computed exactly at every nn. If pm(n)p_m(n) is the chance that a random permutation of nn objects has every cycle of length at most mm, then the cycle containing the first object has each length from 1 to nn with equal probability 1/n1/n, and what remains is a random permutation of the other objects, so

pm(n)=1n∑k=1min⁡(m,n)pm(n−k).p_m(n) = \frac{1}{n} \sum_{k=1}^{\min(m, n)} p_m(n - k).

The figure computes this for ten, thirty and a hundred objects and draws the resulting staircases against Dickman’s curve. At a hundred objects the steps already sit on the curve: the chance of no cycle longer than fifty is 0.31180.3118, within half a percentage point of 1−log⁡21 - \log 2. The convergence is fast — the error shrinks like 1/n1/n — because a permutation has no analogue of the small primes. The same is true at the other end of the cycle structure: how many get their own hat counted the cycles of length one, the objects a shuffle leaves where they were, and found their number settling on its limiting law almost immediately. Every cycle length from 1 to nn is equally available to the first object, and the first object is a uniform sample of the whole.

So the same function appears in two places with different speeds. Shuffles reach it within a hundred cards. Integers have not reached it by ten million, because the role nn plays for shuffles is played for integers by log⁡n\log n — ten million has a logarithm of only sixteen — and because the integers’ small primes give the finite picture a bias that a shuffle does not have. The comparison is the clearest evidence of what ρ\rho describes: not something about primes in particular, but about breaking a whole into pieces at random, one piece at a time, each a uniform share of what remains. A perfect coin and a biased shuffle followed what goes wrong when a shuffle is not uniform; Dickman’s law is what a uniform one looks like from the inside.

How rare smoothness gets

For large uu, Dickman’s function falls faster than any exponential. Roughly, ρ(u)\rho(u) is about u−uu^{-u}; more precisely, log⁡ρ(u)=−u(log⁡u+log⁡log⁡u−1+o(1))\log \rho(u) = -u(\log u + \log \log u - 1 + o(1)), a form de Bruijn gave.

Smoothness gets rare like u to the minus u. ρ(u): 2: 3.0685e-1, 4: 4.9109e-3, 6: 1.9650e-5, 8: 3.2321e-8, 10: 2.7701e-11; counted shares at 10⁷: u=2 3.362e-1, u=3 6.652e-2, u=4 1.157e-2, u=5 2.843e-3, u=6 8.289e-4, u=7 2.155e-4.
Fig. 6 Dickman’s ρ(u)\rho(u) out to u=10u = 10 on a logarithmic scale, the cruder rule u−uu^{-u} dashed, and the share of numbers up to 10710^7 with no prime factor above 107/u10^{7/u}, for u=2u = 2 to 77. ρ(10)=2.77×10−11\rho(10) = 2.77 \times 10^{-11}, 0.28 times u−uu^{-u}. The counted shares lie far above the curve once uu is large, because x1/ux^{1/u} is then small.

The values matter in computation, because smooth numbers are the raw material of every fast method for factoring large integers. Pollard’s p−1p - 1 method finds a prime factor pp quickly when p−1p - 1 is smooth. A collision that finds a factor followed Pollard’s other method, whose speed is set by the birthday problem rather than by smoothness, and which for that reason is slower on the largest numbers. The quadratic sieve and the number field sieve, which hold the records for factoring numbers of no special form, work by finding many numbers in a structured sequence that are smooth, and then combining them; the expected number of tries is 1/ρ(u)1/\rho(u) for the appropriate uu, and the whole art of those methods is choosing sequences whose members are small, so that uu is small, while keeping enough structure to combine them. Hendrik Lenstra’s elliptic curve method of 1987 replaces p−1p - 1 by the size of a random group near pp, and its running time is again an expression in ρ\rho.

The figure’s numbers make the stakes concrete. The chance that a random 60-digit number has no prime factor above a million is ρ(10)=2.77×10−11\rho(10) = 2.77 \times 10^{-11}. The counted points at ten million show again why the limit must be used with care: for u=7u = 7, the bound 107/710^{7/7} is 10, and the numbers counted are those made only of 2, 3, 5 and 7, of which there are far more than ρ(7)\rho(7) predicts — 2,155 in ten million against about nine. Analyses of factoring algorithms use ρ\rho at sizes where the bound has thousands or millions of primes below it, and there the limit is accurate; the figure shows the region where it is not.

What the size of the largest prime adds

The counting essays found that a number’s prime factors, as a list, behave like independent coins — each small prime qq dividing with chance 1/q1/q. Dickman’s law is the same independence seen from the other end. The share of numbers divisible by a prime pp near n1/vn^{1/v}, with no larger prime, can be computed from that independence, and what it gives, summed over pp and taken to the limit, is the delay equation. The two pictures — many small coins, one large piece — are the same probability model, read for the small primes and for the large ones. One way to factor, and no other began this sequence by saying that the factorisation of a number is unique; these last essays have found that it is also, statistically, completely predictable, from the count of its smallest pieces to the size of its largest.

There is one more connection, back to Euclid’s proof run as a machine, which took products of primes plus one and followed their factors. Keeping the largest prime factor at each step instead of the smallest gave a sequence that climbs at once into primes of many digits, passing over small primes as factors it does not keep, and Andrew Booker proved that it misses infinitely many primes. The speed of the climb is what Dickman’s law predicts for a typical number: its largest prime factor carries, on average, about 62 per cent of its digits, and a sequence that keeps only that factor discards the rest at every step.

Still open: the joint law at consecutive numbers

Dickman’s law describes one number at a time. For two consecutive numbers nn and n+1n + 1, the natural guess is that their largest prime factors are independent, so that, for example, the chance that both are x\sqrt{x}-smooth is ρ(2)2≈0.094\rho(2)^2 \approx 0.094. Nothing contradicts this, and counts like the ones above agree with it, but it is not proved in general; even simple consequences, such as P(n)<P(n+1)P(n) < P(n+1) holding for exactly half of all nn, have needed the strongest modern methods for correlations of multiplicative functions. The difficulty is the same one met at the end of the same bell on thinner sets: correlations between the prime factors of nearby numbers are questions about primes in short intervals and polynomial patterns, and they lie beyond the reach of sieves.

A second open question is quantitative. The smooth counts in the figures stay well above xρ(u)x\rho(u) at every size that can be enumerated, and the better approximations to Ψ(x,y)\Psi(x, y) — de Bruijn’s expansion, and saddle-point methods that track the actual primes below yy — are accurate but not explicit in the way ρ\rho is. A practical, provable estimate that is good at the sizes cryptographers care about, with error bounds that can be stated in advance, would settle a number of security estimates that are currently made by extrapolating counts like these, and it does not yet exist.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

AsymptoticsCycleDifferential equationFactoringLargest prime factorPermutationPrime factorisationSieveSmooth number