Benford behavior and distribution in residue classes of large prime factors

Abstract We investigate the leading digit distribution of the kth largest prime factor of n (for each fixed 
$k=1,2,3,\dots $
 ) as well as the sum of all prime factors of n. In each case, we find that the leading digits are distributed according to Benford’s law. Moreover, Benford behavior emerges simultaneously with equidistribution in arithmetic progressions uniformly to small moduli.


Introduction
Benford's law, named for physicist Frank Benford (though discovered almost 60 years prior by Simon Newcomb), refers to the observation that in many naturally occurring datasets, the leading digits are far from uniformly distributed, with smaller digits more likely to occur. Let us make this precise. By the N leading digits of the positive real number x, we mean the N most significant digits. For example (working in base 10), 123.456 has the first 4 leading digits 1234, and this is the same for 0.00123456. Now, let D and b be integers with b ≥ 2. We say a positive real number "begins with D in base b" if its most significant digits in base b are those of the base b expansion of D. Then Benford's law, in base b, predicts that the proportion of terms in the dataset beginning with D should be approximately log(1 + D −1 )/ log b. For example, since log 2 log 10 = 0.3010 . . . , we expect to see a leading digit 1 in base 10 about 30% of the time.
For general background on Benford's law, see [5,22]. In this paper, we are interested in datasets arising from positive-valued arithmetic functions. Let f ∶ N → R >0 . We say f obeys Benford's law in base b (or that f is Benford in base b) if, for each positive integer D, the asymptotic density of n for which f (n) begins with D in base b is log(1 + D −1 )/ log b. Results on the "Benfordity" of particular arithmetic functions are scattered throughout the literature. For example, f (n) = n! is Benford in every base b [11], as is the "primorial" f (n) = ∏ n k=1 p k [21]. The classical partition function p(n) is also Benford in every base (see [2] or [21]). On the other hand, f (n) = n is not Benford; the asymptotic density in question does not exist. This same obstruction to Benford's law persists if f (n) is any positive-valued polynomial function of n. (See, for instance, the final section of [21]. It should be noted that these examples obey Benford's law in a weaker sense; namely, Benford's law holds if asymptotic density is replaced with logarithmic density.) When f is multiplicative, whether or not f is Benford in base b can be interpreted as a problem in the theory of mean values of multiplicative functions. Namely, f is Benford precisely when f (n) 2πi / log b has mean value zero for each nonzero integer . This criterion was noted by Aursukaree and Chandee [3] and used by them to show that the divisor function d(n) is Benford in base 10. A more systematic study of the Benford behavior of multiplicative functions, leveraging Halász's celebrated mean value theorem, was recently undertaken in [8]. For example, it is shown there that ϕ(n) is not Benford, but that |τ(n)| is, where τ is Ramanujan's τ-function. 1 All of the work in [8] is carried out in base 10, but both of the quoted results hold, by simple modifications of the proofs, in each fixed base b ≥ 2.
Our concern in the present paper is with certain nonmultiplicative functions. Roughly speaking, we show that (for each fixed k) the kth largest prime factor of n obeys Benford's law, as does the sum of all of the prime factors of n. (Both results hold for each base b.) In fact, our results are somewhat stronger than this.
We let P k (n) denote the kth largest prime factor of n; when k = 1, we write P(n) in place of the more cumbersome P 1 (n). More precisely, if n = p 1 p 2 p 3 ⋯p Ω(n) , with (When k = 1, it is usual to write Ψ(x, y) in place of Ψ 1 (x, y).) Let a mod q be a coprime residue class. For real x, y ≥ 2, define Ψ k (x, y; b, D, q, a) ∶= #{n ≤ x ∶ P k (n) ≤ y, P k (n) ≡ a (mod q), P k (n) begins with D in base b}. Theorem 1.1 Fix positive integers k, b, and D, with b ≥ 2. Fix real numbers U ≥ 1 and ε > 0. Then as x, y → ∞, uniformly for y ≥ x 1/U and coprime residue classes a mod q with q ≤ log x (log log x) k−1+ε . In fact, if k = 1, we can take q ≤ (log x) A for any fixed A.
To deduce that P k (n) is Benford, it suffices to take q = 1 and y = x. The additional generality of Theorem 1.1 seems of some interest. For example, Theorem 1.1 contains the result of Banks-Harman-Shparlinski [4] that P(n), on integers n ≤ x, is uniformly distributed in coprime residue classes mod q, for q up to an arbitrary fixed power of log x. Theorem 1.1 gives the corresponding result for P k (n), when k > 1, in the more restricted range q ≤ log x/(log log x) k−1+ε . This appears to be new; more-over, this range of q is sharp up to the power of log log x, since ≫ x(log log x) k−2 / log x values of n ≤ x have P k (n) = 2.
Turning to the sum of the prime factors, we let A(n) = ∑ p k ∥n kp. That is, A(n) is the sum of the prime factors of n, counting multiplicity. (The sum of the distinct prime factors of n could be handled by similar arguments.) The function A(n) was introduced by Alladi and first investigated by Alladi and Erdős [1]. Define as x, y → ∞, uniformly for y ≥ x 1/U and residue classes a mod q with q ≤ (log x) As before, taking y = x and q = 1 shows that A(n) satisfies Benford's law. Again, the extra generality here seems interesting. For example, it is implicit in Theorem 1.2 that A(n) is equidistributed mod q, uniformly for q ≤ (log x) 1 2 −ε , a result which we have not seen explicitly stated in the literature before. (See [12] for the case of fixed q.) The same range of uniformity may follow from the method of Hall in [15] (who considered the distribution mod q of ∑ p|n, p∤q p), but our proof exhibits the result as a simple consequence of quantitative mean value theorems.

Notation
Most of our notation is standard. Of note, we allow constants in O-symbols to depend on any parameter that has been declared as "fixed. " When we refer to "large" x, the threshold for large enough may also depend on these parameters. We write A ≳ B as an abbreviation for A ≥ (1 + o(1))B.
The following result, which connects the ρ k with the distribution of P k (n), appears as equation (4.7) in [19] (and is a consequence of the stronger assertion (4.8) shown there).

Proposition 2.1 Fix a positive integer k and a real number
(In [19], it is assumed that the ratio log x log y is fixed, rather than merely bounded. However, the proof given actually establishes (2.2) in the full range of Proposition 2.1.) The next result is a variant of Theorem 1.1 where we require that P k (n) be bounded below by a fixed power of x.

Proposition 2.2 Fix positive integers k, b, and D with b ≥ 2. Fix real numbers
log y , where x, y → ∞ with y ≥ x 1/U , and where a mod q is a coprime residue class with q ≤ (log x) A .
The proof of Proposition 2.2 requires two classical results from the theory of primes in arithmetic progressions. Let π(x; q, a) denote the count of primes p ≤ x with p ≡ a (mod q).

Proposition 2.3 (Brun-Titchmarsh) If a and q are coprime integers with
Here, the implied constant is absolute.

Proposition 2.4 (Siegel-Walfisz)
Fix a real number A > 0. If a and q are coprime integers with 1 ≤ q ≤ (log x) A , and x ≥ 3, then Here, C is a certain absolute constant. Proof of Proposition 2.2 First note that we can (and will) always assume that y ≤ x, since the cases when y > x are covered by the case y = x.
By a standard compactness argument, when proving Proposition 2.2, we may assume that u = log x log y is fixed. To see this, suppose Proposition 2.2 holds when u is fixed but does not hold in general. Then, for some ε > 0, there are choices of x, y, a, and q with x arbitrarily large, x ≥ y ≥ x 1/U , and q ≤ (log x) A for which our count exceeds or there are such choices of x, y, a, and q for which our count falls below We will assume that we are in the former case; the latter can be handled analogously. By compactness, we may choose x, y, a, q so that u → u 0 , for some u 0 ∈ [1, U].
We first rule out u 0 = 1. As y ≤ x, the condition P k (n) ≤ y is always at least as strict as the condition P k (n) ≤ x (which holds vacuously, as we are counting numbers n ≤ x). Moreover, the u = 1 case of Proposition 2.2 is true by hypothesis. Putting these observations together, we see that the count of n corresponding to x, y, a, q is at most However, if u → 1, then ρ k (u) → ρ k (1), and this estimate is eventually incompatible with (2.3). Thus, it must be that u 0 > 1. Here, we may obtain a contradiction by a slightly tweaked argument. For any fixed δ > 0, we eventually have u > u 0 − δ. So the condition P k (n) ≤ y is eventually stricter than the condition P k (n) ≤ x 1/(u0−δ) . If δ is fixed sufficiently small (in terms of ε), then the u = u 0 − δ case of Proposition 2.2 gives an estimate contradicting (2.3).
We thus turn to proving the modified statement with the extra condition that u is fixed.
For each nonnegative integer j, let I j denote the interval Then our count of n is given by Let J be the collection of nonnegative integers j with I j ⊂ (x 1/U ′ , y/ exp( √ log x)). Then, at the cost of another error of size o(x/ϕ(q)), we can restrict the triple sum in (2.5) to j ∈ J. Indeed, the n counted by the triple sum above that are excluded by this restriction have either a prime divisor in P ∶= ( , y], and the number of such n ≤ x is at most by partial summation and the Brun-Titchmarsh theorem (Proposition 2.3). We proceed to estimate, for each j ∈ J, the corresponding inner sums in (2.5) over p and n.
If p is prime and P k (n) = p, then n = mp where m ≤ x/p, P k (m) ≤ p, and P k−1 (m) ≥ p. The converse also holds. Thus, if j ∈ J and p ∈ I j , To continue, observe that, for j ∈ J, where m and M are defined by and where the last displayed sum on n is understood to be extended only over those n ≤ x/u j for which m ≤ M. By the Siegel-Walfisz theorem (Proposition 2.4), where C is an absolute positive constant and C ′ = C/ √ U ′ . (This use of the Siegel-Walfisz theorem explains the restriction q ≤ (log x) A in the statement of 632 P. Pollack and A. Singha Roy Proposition 2.2.) Putting this back in the above and summing on n, we find that (for large x) (2.6) A nearly identical calculation gives the same bound for the difference Since u j+1 /u j ≥ 2 and the smallest j ∈ J has u j ≥ x 1/U ′ , the expression on the righthand side of (2.6), when summed on j ∈ J, is ≪ x(log x) 2 exp(−C ′ √ log x) + x 1−1/U ′ , and this is certainly o(x/ϕ(q)). As a consequence, instead of our original triple sum (2.5), it is enough to estimate We now apply Proposition 2.1, noting that for each t ∈ I j , we have The error term, when summed on j ∈ J, is ≪ 1 √ log x, and so is o(1); inserted back into (2.7), we see that this gives rise to a final error of size o(x/ϕ(q)) in our count, which is acceptable. To deal with the remaining integrals, we write u j = x μ j and v j = x ν j and make the change of variables α = log x log t . Then , so that this last sum on j simplifies to ∑ j∈J (ρ k (1/ν j ) − ρ k (1/μ j )). Now, following [19], we introduce the function F k (β) defined for β ∈ (0, 1] by F k (β) = ρ k (1/β). By the mean value theorem, for some t j ∈ (μ j , ν j ). Thus, Since each t j ∈ (μ j , ν j ) ⊂ (μ j , μ j+1 ), the final sum on j is essentially a Riemann sum.
To make this precise, let j 0 = min J and j 1 = max J. Then is a genuine Riemann sum for ∫ , whose mesh size goes to 0 as x → ∞. However, the terms we have added to the sum on j ∈ J contribute o(1), as x → ∞.
Collecting estimates completes the proof of the proposition in the case when u is fixed. ∎ To deduce Theorem 1.1, it remains to handle the contribution from n with P k (n) ≤ x 1/U ′ . The following lemma bounds the number of integers with a large smooth divisor. A proof is sketched in Exercise 293 on page 554 of [26], with a solution in [25, pp. 305-306]. By the y-smooth part of a number n, we mean ∏ p e ∥n p≤y p e .

Lemma 2.5
For all x ≥ z ≥ y ≥ 2, the number of n ≤ x whose y-smooth part exceeds z is O (x exp (− 1 2 log z log y )).

Lemma 2.6 Fix a positive integer k and a real number B ≥ 1.
• When k = 1, the number of n ≤ x with P k (n) ≤ y and P k (n) ≡ a (mod q) is uniformly for x ≥ y ≥ 3 with y ≤ x 1/4 , and a mod q any coprime residue class with q ≤ x 1/8 . As usual, u = log x log y . • When k ≥ 2, the number of n ≤ x with P k (n) ≤ y and P k (n) ≡ a (mod q) is uniformly in the same range of x, y, and q.
Proof We will restrict attention to n > x 3/4 ; this is permissible, since x 3/4 is dwarfed by either of our target upper bounds. We let p = P k (n) and write n = p 1 ⋯p k−1 ps, where p 1 ≥ p 2 ≥ ⋅ ⋅ ⋅ ≥ p k−1 ≥ p and P(s) ≤ p.
We first show that we can assume s ≤ x 1/2 . Indeed, suppose s > x 1/2 . Then, with m = n/p, we have that m ≤ x/p and that the p-smooth part of m exceeds x 1/2 . Applying Lemma 2.5, we see that for every p ≤ y, the number of corresponding m is Now, we sum on p ≤ y with p ≡ a (mod q). We split the sum at 3q 2 , using Mertens' theorem to bound the first half and the Brun-Titchmarsh theorem (with partial summation) for the second; this gives Substituting this estimate into the previous display, we conclude that the n with This is already enough to settle the k = 1 case of Lemma 2.6. Indeed, in that case, n = ps, where p = P(n), and s = n/P(n) ≥ n/y > x 3/4 /y ≥ x 1/2 . Now, suppose that k ≥ 2 and that s ≤ x 1/2 . Then so that p 1 ≥ x 1/4k . Hence, given p 2 , . . . , p k−1 , p, and s, the number of possibilities for p 1 (and thus also for n) is ≪ π(x/p 2 ⋯p k−1 ps) ≪ x/p 2 ⋯p k−1 ps log x. Observe that s is p-smooth, while each p i ∈ [p, x]. We have that ∑ s p-smooth 1/s = ∏ prime ≤p (1 − 1/ ) −1 ≪ log p. Moreover (when p ≤ y), Hence, the number of possibilities for n given p is We now sum on p ≤ y with p ≡ a (mod q). Estimating crudely, we see that the p ≤ 3q 2 contribute To handle the remaining contribution in the case when y > 3q 2 , we apply partial summation; by Brun-Titchmarsh, Integrating by parts again,

Making the change of variables
(In the last step, we use that ∫ z 0 (log(1/α)) k−2 dα has the form z ⋅ Q(log(1/z)), where Q is a monic polynomial with degree k − 2.) Collecting estimates, we conclude that 636 P. Pollack and A. Singha Roy when k ≥ 2, the n with s ≤ x 1/2 make a contribution Since this upper bound dominates the contribution (2.8) from n with s > x 1/2 , the k ≥ 2 cases of Lemma 2.6 follow. ∎ Proof of Theorem 1.1 Fix η > 0. We will show that the count of n in question is eventually 2 larger than 1 x and eventually smaller than The required lower bound is immediate from Proposition 2.2: it suffices to apply that proposition with U ′ fixed large enough that ρ k (U ′ ) < η.
We turn now to the upper bound. Apply Lemma 2.6, taking B = A + 1 in the case k = 1. That lemma implies the existence of a constant C, depending only on k (and on A, if k = 1) such that the following holds: for any fixed U ′ ≥ 4, the number of n ≤ x with P k (n) ≡ a (mod q) and P k ( , the desired upper bound then follows from Proposition 2.2. For multiplicative functions F, G taking values on or inside the complex unit circle, we define (following [13]) the distance between F and G, up to x, by The following statement (Corollary 4.12 on page 494 of [26]), due to Montgomery and Tenenbaum, makes quantitatively precise a result of Halász [14] that F has mean value 0 unless F "pretends" to be n it for some t. 2 Here and later in this proof, "eventually" refers to the limit as taken in Theorem 1.1. That is, a statement holds eventually if there is a real number T such that the statement is true whenever x, y ≥ T, with y ≥ x 1/U , and with a mod q a coprime residue class modulo q ≤ log x (log log x) k−1+ε or, when k = 1, modulo q ≤ (log x) A .
Here, the implied constant is absolute.
When F is real-valued, the following (slightly weakened version of a) theorem of Hall and Tenenbaum [16] allows us to consider only D(F, 1; x).

Proposition 3.2 Let F be a real-valued multiplicative function with |F(n)| ≤ 1 for all n. Then
for all x ≥ y ≥ x 1/U and residue classes a mod q with q ≤ log x.
Proof By the orthogonality relations for additive characters, ∑ n≤x P(n)≤y A(n)≡a (mod q) e −2πi ar/q ∑ n≤x 1 P(n)≤y e 2πirA(n)/q . Hence, it suffices to show that for each nonzero residue class r mod q.
When q ′ > 2, we apply Proposition 3.1 taking T = log x. Let t be any real number with |t| ≤ T. We set z = exp((log x) δ ) and start from the lower bound Lemma 3.7 Fix positive integers N and b, with b ≥ 2, and fix a real number ε > 0. Among all n ≤ x with A(n) ≡ a (mod q), the number of n for which the N leading base b digits of P(n) do not coincide with those of A(n) is o(x/q), as x → ∞, uniformly in residue classes a mod q with q ≤ (log x) 1 2 −ε .
Proof Since b and N are fixed, it is enough to prove the estimate of the lemma under the assumption that the N leading digits in the base b expansion of P(n) are fixed, say as the digits of the positive integer D.
For M a (fixed) positive integer to be specified momentarily, we let D ′ be the integer obtained by tacking M copies of the digit "b − 1" on to the end of the b-ary expansion of D. Thus, Suppose P(n) begins with D in base b, but A(n) does not. We take two cases. First, it may be that P(n) begins with D but not D ′ ; in that case, for A(n) to not begin with D, we must have A(n)/P(n) > 1 + 1/D ′ . By Lemma 3.6, the number of such n ≤ x is O(x(log log x) 2 / log x), which is o(x/q). On the other hand, if P(n) begins with D ′ , we apply Proposition 3.5. Taking y = x there, we see that the number of n ≤ x for which P(n) begins with D ′ and A(n) ≡ a (mod q) is ∼ log(1+1/D ′ ) log b x q . Since the coefficient of x q in this estimate can be made as small as we like by fixing M large enough, we obtain the lemma. ∎ Theorem 1.2 follows from combining Proposition 3.5 with Lemma 3.7.

Remark
The range of uniformity in q can be widened under the assumption that q is supported on sufficiently large primes. More precisely, for any fixed Q ≥ 2, the result of Theorem 1.2 holds uniformly for q ≤ (log x) 1−1/Q−ε , provided the least prime P − (q) dividing q is at least Q + 1. The key observation is that, in the notation of Lemma 3.3, such q have ϕ(q ′ ) ≥ P − (q) − 1 ≥ Q, which shows that π(I) ϕ(q ′ )u (ϕ(q ′ ) − Re(μ(q ′ )u −it )) ≥ (1 − 1 Q ) π(I) u in the display (3.4). The remainder of the proof requires only minor modifications.