A prime that adds up to its own square
Start at 13 and add the next six primes: 13 + 17 + 19 + 23 + 29 + 31 + 37 = 169 = 13². Seven consecutive primes, beginning with 13, sum to exactly the square of 13.
I stumbled on this while playing with sums of consecutive primes, and it raised an obvious question. Which primes p have the property that p² equals the sum of consecutive primes starting at p itself? Call such a prime a self-square prime. The answer turns out to be a very short list: below 150 million there are exactly three, and a simple heuristic suggests there may never be many more.
Why seven terms works for 13 and nothing else
Fix the number of terms at seven and try every starting prime. The sum grows roughly like 7p, a straight line; the square p² grows as a parabola. For small p the sum is ahead, the parabola overtakes it between 13 and 17, and the gap only widens from there.
| Starting prime p | Sum of 7 consecutive primes from p | p² | |
|---|---|---|---|
| 2 | 2 + 3 + 5 + 7 + 11 + 13 + 17 = 58 | 4 | sum > square |
| 3 | 75 | 9 | sum > square |
| 5 | 95 | 25 | sum > square |
| 7 | 119 | 49 | sum > square |
| 11 | 143 | 121 | sum > square |
| 13 | 13 + 17 + 19 + 23 + 29 + 31 + 37 = 169 | 169 | equal |
| 17 | 197 | 289 | sum < square |
| 19 | 223 | 361 | sum < square |
| 23 | 251 | 529 | sum < square |
| … | … | … | gap keeps growing |
| 199 | 1,561 | 39,601 | sum < square |
The line and the parabola cross exactly once, and they happen to cross at a prime. Seven is also the smallest number of terms that works for any prime at all: with two to six terms, no prime reaches its own square. The same argument shows that for any fixed number of terms k there can only be finitely many solutions, all with p not much larger than k.
Drop the seven: only three primes below 150 million
Now allow any number of terms. For each prime p, keep adding consecutive primes and stop when the running total reaches p². Checking every prime below 150,000,000 (a sieve up to 1.1 billion plus a two-pointer scan, a few seconds in C) gives exactly three hits:
| Self-square prime p | p² | Number of terms | Last prime added |
|---|---|---|---|
| 13 | 169 | 7 | 37 |
| 463 | 214,369 | 191 | 1,811 |
| 10,301 | 106,110,601 | 3,691 | 48,091 |
So 13 + 17 + … + 37 = 13², 463 + 467 + … + 1811 = 463², and 10301 + 10303 + … + 48091 = 10301². No fourth prime appears anywhere up to 150 million.
Notice how the three differ in character. 13 needs seven terms and is something you can check by hand. 463 needs 191 terms; 10301 needs 3,691. The number of terms grows roughly in step with p (a little slower, since primes thin out), and the last prime added has to sit well above p: about 3p for 13, 4p for 463, 5p for 10301, and around 6.5p by the time p reaches 150 million.
Why they are so rare
A simple probabilistic model explains the scarcity and suggests the list may already be complete.
Parity first. For an odd prime p, p² is odd. A sum of consecutive odd primes is odd only when the number of terms is odd, so every solution must use an odd number of terms. 7, 191 and 3691 all are.
How far the sum has to run. Summing the primes from p up to q gives roughly (q² − p²) / (2 ln q). Setting this equal to p² gives q ≈ p · √(1 + 2 ln q), which matches the observed ratios (2.9, 3.9, 4.7) well. So by the time the running total approaches p², each step adds a prime of size roughly 5p to 7p.
The hitting probability. Near the target, consecutive partial sums are spaced about q apart. Treating the exact value p² as a random point among the integers of that size, the chance that some partial sum lands on it is about 1/q. The expected total number of self-square primes is then the sum of 1/q(p) over all primes p, and because q grows like p√(2 ln p), that sum converges:
Σp 1/q(p) ≈ ∫ duu √(2u + 1) < ∞ (u = ln p)
Putting numbers in: the model expects about 0.8 solutions below 150 million (we found 3, which is a little lucky but not remarkable with counts this small) and about 0.3 more in the entire infinite tail beyond it. Only about 0.05 of that tail sits below 10¹², and about 0.1 below 10¹⁸. If the model is right, there is roughly a one-in-four chance that a fourth self-square prime exists at all, and if it does it is almost certainly far beyond anything a home computer can reach.
This is a heuristic, not a proof. Nobody knows how to prove that the list is finite, and there is no obvious route to one; the question is of the same flavour as many unsolved statements about sums of consecutive primes.
Is this already known?
The identity for 13 is not new. Wikipedia's page on 169 notes that it is the sum of seven consecutive primes, 13 through 37, and OEIS A132956 (the smallest square that is a sum of n consecutive primes) records 169 as the entry for n = 7. A163244 lists squares that are sums of consecutive primes at all.
What I could not find anywhere is the self-referential version: the sum starting at p and landing exactly on p². As far as I can tell no OEIS entry begins 13, 463, 10301, and Prime Curios! has other curios for 13, 463 and 10301 but not this one. That is the result of a search, not a proof of novelty. If you know of an earlier reference, I would like to hear about it: [email protected].
Two companion sequences come with it: the number of terms (7, 191, 3691) and the last prime added (37, 1811, 48091).
Verify it yourself
The search up to 50,000 takes a few seconds in plain Python with no libraries; it prints all three self-square primes.
def primes_up_to(n):
s = bytearray([1]) * (n + 1); s[:2] = b"\x00\x00"
for i in range(2, int(n ** 0.5) + 1):
if s[i]: s[i*i::i] = bytearray(len(s[i*i::i]))
return [i for i, v in enumerate(s) if v]
P = primes_up_to(400_000) # enough for starting primes up to 50,000
for j, p in enumerate(P):
if p > 50_000: break
total, k = p, j
while total < p * p:
k += 1; total += P[k]
if total == p * p:
print(p, "terms:", k - j + 1, "last prime:", P[k])
Output:
13 terms: 7 last prime: 37
463 terms: 191 last prime: 1811
10301 terms: 3691 last prime: 48091
The 150-million search used the same two-pointer idea in C with a bit-packed sieve up to 1.1 billion; the running total never needs to be recomputed from scratch, so the whole scan is linear in the number of primes.
What this is, and what it isn't
This is recreational mathematics, not research. The property does not connect to any larger structure, and the heuristic above suggests the three solutions are what a random model would produce, give or take. Nothing here would help with prime gaps, twin primes or anything else people actually care about.
It does meet every test of a good curiosity: one sentence to state, checkable by hand for 13, a surprisingly short answer, and a clean reason why the list should be short. That is enough to be worth writing down. The identity 13 + 17 + 19 + 23 + 29 + 31 + 37 = 13² is the only member of the family you can carry in your head, and it is a nice thing to carry.
If you find a fourth self-square prime, or a reference that predates this note, email me at [email protected]. I will update this page.
Henry John Wynn, September 2026.