y4
y4
y4
Cathal O’Sullivan1
Department of Mathematics, Statistics, and Actuarial Science, and Department of
Computer Science and Software Engineering, Butler University, Indianapolis,
Indiana
Jonathan P. Sorenson
Department of Computer Science and Softare Engineering, Butler University,
Indianapolis, Indiana
[email protected]
Aryn Stahl2
Department of Physics and Astronomy, and Department of Computer Science and
Software Engineering, Butler University, Indianapolis, Indiana
Abstract
For an integer k > 1, let sk (x) count the number of representations of integers
n ≤ x as the sum of kth powers of consecutive primes. We present and analyze an
algorithm to enumerate all such integers n and an algorithm to compute the value of
sk (x). We also present asymptotic upper and lower bounds on sk (x) that are within
a constant factor of one another. In particular, we show that sk (x) ∼ x2/(k+1)+o(1) .
This work extends previous work by Tongsomporn, Wananiyakul, and Steuding
(2022) who examined sums of squares of consecutive primes.
1. Introduction
Let Sk (x) denote the set of integers n ≤ x that can be written as a sum of the kth
powers of consecutive primes. For example, 53 + 73 + 113 = 1799 is an element of
S3 (2000). Let sk (x) be the number of such n, counted with multiplicity. If a specific
integer n has more than one representation as the sum of kth powers of consecutive
primes, we count all such representations when we say ”with multiplicity”. So we
have sk (x) ≥ #Sk (x).
DOI: 10.5281/zenodo.10450932
1 Current affiliation: AbbVie, Lake Bluff, Illinois
2 Current affiliation: Naval Surface Warfare Center, Crane, Indiana
INTEGERS: 24 (2024) 2
In this paper, we describe an algorithm that, given k and x, produces the elements
of Sk (x) along with their representation. Its running time is linear in sk (x), the
number of such representations. The algorithm uses O(kx1/k ) space. This is Section
2. In Section 3, we describe a second algorithm that computes the value of sk (x),
with multiplicity, given k and x. This algorithm takes O(x1/k / log log x) arithmetic
operations, the time it takes to find all primes up to x1/k . In Section 4 we show
that
x2/(k+1)
sk (x) ≤ (1 + o(1)) · ck ,
(log x)2k/(k+1)
where ck = (k 2 /(k − 1)) · (k + 1)1−1/k . This is a generalization of a bound for s2 (x)
proven in [6]. Their bound is explicit and ours is not. This is also an upper bound
on the number of arithmetic operations used by our enumeration algorithm. Also
in Section 4, we give the lower bound
(k + 1)2 x2/(k+1)
sk (x) ≥ (1 + o(1)) · ,
2 (log x)2k/(k+1)
In Section 5 we apply our new algorithm to compute Sk (x) for various x and k, and
give some examples of integers that can be written as sums of consecutive powers
of primes in more than one way. Note that S2 (5000) was computed by [6]; see also
sequence A340771 at the On-Line Encyclopedia of Integer Sequences [1].
We begin by describing our enumeration algorithm in the next section.
Given as input a bound x and integer exponent k > 1, our algorithm produces the
elements of the set Sk (x) as follows.
Let p1 = 2, p2 = 3, . . . denote the primes, and let π(y) denote the number of
primes less than or equal to y. By the Prime Number Theorem (see, for example,
[4]), π(y) ∼ y/ log y, and thus p` ∼ ` log `.
We assume all arithmetic operations take constant time. In practice, all our
integers are at most 128 bits, or roughly 38 decimal digits.
The three steps of our algorithm are as follows:
2. Compute the prefix sum array f [ ], where f [0] = 0 and f [i] := pk1 +pk2 +· · ·+pki
for all i ≤ π(x1/k ), so that f [i + 1] = f [i] + pki+1 .
0 1 2 3 4
0 8 35 160 503
3. A Counting Algorithm
count := 0; t := 0;
while(t < π(x1/k ) and f [t + 1] ≤ x) do:
t := t + 1;
for b := 0 to π(x1/k ) − 1 do:
if t < π(x1/k ) and f [t + 1] − f [b] ≤ x then
t := t + 1;
count := count + (t − b);
It is easy to see that the running time for the last step is O(π(x1/k )) arithmetic oper-
ations. So finding the primes in Step 1 dominates the running time, at O(x1/k / log log x)
time using, say, the Atkin-Bernstein prime sieve [2].
4. Analysis
In this section we prove the following theorem, which provides an upper bound on
sk (x).
x2/(k+1)
sk (x) ≤ (1 + o(1)) · ck ,
(log x)2k/(k+1)
Note that ck ∼ k 2 for large k. In [6] the authors prove the explicit bound
x2/3
s2 (x) ≤ 28.4201 .
(log x)4/3
We also have the trivial lower bound sk (x) ≥ π(x1/k ) ∼ kx1/k / log x by the Prime
Number Theorem.
Our proof follows the same lines as in [6]. We begin by partitioning the members
of Sk (x) by the number of prime powers m in their representative sum. Define
x1/(k+1)
M (x, k) ∼ (k + 1) .
(log x)k/(k+1)
Proof. We have
M
X M
X +1
pk` ≤ x < pk` .
`=1 `=1
Using the asymptotic estimate pM ∼ M log M from the Prime Number Theorem
and using the methods from [3, Section 2.7] we have
M
X X Z M log M
pk` ∼ pk = tk dπ(t)
`=1 p≤M log M 2
M log M M log M
tk
Z Z
1
∼ dt ∼ tk dt,
2 log t log M 2
and so we have
(M log M )k+1
x∼ .
(k + 1) log M
Taking the logarithm of both sides gives us (k + 1) log M ∼ log x. We then obtain
that
M ∼ (k + 1)(x log x)1/(k+1) / log x.
Proof. We have
M
X M
X
sk (x) = sk,m (x) ≤ π((x/m)1/k ).
m=1 m=1
INTEGERS: 24 (2024) 6
Plugging in our estimate for M from Lemma 2 gives this bound for sk (x):
1−1/k
kx1/k k x1/(k+1)
(k + 1) .
log x k − 1 (log x)k/(k+1)
(k + 1)2 x2/(k+1)
M
sk (x) ≥ ≥ (1 + o(1)) · .
2 2 (log x)2k/(k+1)
Proof. Consider the sum pk1 + · · · + pkM , which is at most x by definition. The
lower bound is obtained by counting the number of i, j pairs with 1 ≤ i ≤ j ≤ M ,
which is M k k
2 , as each sum pi + · · · + pj gives an integer n counted by sk (x). Thus,
sk (x) ≥ M (M − 1)/2, and apply Lemma 2.
5. Empirical Results
In this section we give some of our empirical results. This is not everything we have
– the interested reader is encouraged to contact the second author for copies of the
data or source code.
Table 3: Values of s5 (x), with upper Table 4: Values of s10 (x), with upper
and lower bounds and lower bounds
INTEGERS: 24 (2024) 9
5.2. Duplicates
We found 40 values of n ≤ x = 1012 that have multiple representations as sums of
consecutive squares of primes. The smallest such number is 14720439, which can
be written as
9412 + 9472 + 9532 + 9672 + 9712 + 9772 + 9832 + 9912 + 9972 + 10092 +
10132 + 10192 + 10212 + 10312 + 10332
and as
1312 + 1372 + 1392 + 1492 + 1512 + 1572 + 1632 + 1672 + 1732 + 1792 +
1812 +1912 +1932 +1972 +1992 +2112 +2232 +2272 +2292 +2332 +2392 +
2412 +2512 +2572 +2632 +2692 +2712 +2772 +2812 +2832 +2932 +3072 +
3112 +3132 +3172 +3312 +3372 +3472 +3492 +3532 +3592 +3672 +3732 +
3792 +3832 +3892 +3972 +4012 +4092 +4192 +4212 +4312 +4332 +4392 +
4432 +4492 +4572 +4612 +4632 +4672 +4792 +4872 +4912 +4992 +5032 +
5092 +5212 +5232 +5412 +5472 +5572 +5632 +5692 +5712 +5772 +5872 +
5932 +5992 +6012 +6072 +6132 +6172 +6192 +6312 +6412 +6432 +6472 .
To find these, we sorted the output of our algorithm from Section 2, and then used
the uniq -D unix/linux command to list the duplicates.
We found no integers that can be written as the sum of consecutive powers of
primes in more than one way for any power larger than 2. We searched for cubes up
to 1018 , fifth powers up to 1027 , and tenth and twentieth powers up to 1038 . This
INTEGERS: 24 (2024) 13
search requires computing Sk (x) and not just sk (x); note that it is much faster to
compute just sk (x) in practice because outputting the elements of Sk (x) to a text
file slows down the computation considerably.
We found exactly one example with differing powers:
23939 = 232 + 292 + 312 + 372 + 412 + 432 + 472 + 532 + 592 + 612 + 672
= 173 + 193 + 233 .
We conclude this subsection with the list of 40 integers up to 1012 that can be
written as sums of squares of consecutive primes in two ways. For each such integer
in the Table 6, we list the starting primes for each of their two ways to sum.
6. Future Work
Acknowledgements. The authors are grateful to Frank Levinson for his support of
computing research infrastructure at Butler University. The first and third authors
were Butler University undergraduates at the time this work was done.
References
[1] The On-Line Encyclopedia of Integer Sequences, https://oeis.org.
[2] A. O. L. Atkin and D. J. Bernstein, Prime sieves using binary quadratic forms, Math. Comp.
73 (2004), 1023–1030, URL http://cr.yp.to/papers.html#primesieves.
[3] E. Bach and J. O. Shallit, Algorithmic Number Theory, vol. 1, MIT Press, Cambridge Mas-
sachusetts, 1996.
[4] G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers, Oxford University
Press, Oxford, 5th edn., 1979.
[5] J. P. Sorenson, Two compact incremental prime sieves, LMS J. Comput. Math. 18 (2015),
675–683, URL http://journals.cambridge.org/article S1461157015000194.
[6] J. Tongsomporn, S. Wananiyakul, and J. Steuding, Sums of consecutive prime squares, Integers
22 (2022), #A9.