So you are interested in Prime Numbers and puzzles thereof. You saw the following on PSE and gave it a try and got it long after the correct answer was posted by @hexomino.

My Eight Cousins

But then you think that you could design another puzzle.

So you start with 2 prime numbers say A and B with B > A

Then you put another Prime C (C>B) in there.

Turns out B is the average of the three numbers! That is nice.

Then you put another Prime D (D>C) with them. You guessed it.

Now C is the average of A,B,C and D!

Then you put another Prime number E (E>D) with them.

Sure enough now D is the average of A,B,C,D and E!

Now you are excited. You think you have discovered something great. Shake up the Math world??

So you continue with another prime F>E. And yes same thing! E is the average of A to F.

You continue these steps until your bubble bursts when you get the number 5917. Oh no. It is not a Prime.

So you wonder. Is this the longest sequence you can do or is there a sequence longer than one you have discovered? How do you explain this anyway? Is there a math equation for this?

So how many total numbers were in this sequence?

  • $\begingroup$ At a perfunctory glance I've come up with a 9-term sequence which ends in 231,173 (not prime). $\endgroup$
    – RayDansh
    Commented Jan 29, 2021 at 14:42
  • $\begingroup$ @RayDansh Vf gurer na rkcynangvba nf gb jul guvf glcr bs frdhrapr qbrf abg pbagvahr? $\endgroup$
    – DrD
    Commented Jan 29, 2021 at 14:49
  • $\begingroup$ V pna'g frr bar nf bs lrg, ohg V unira'g ybbxrq ng vg gbb qrrcyl rvgure. $\endgroup$
    – RayDansh
    Commented Jan 29, 2021 at 14:54

3 Answers 3


The sequence you tried is


So how many total numbers were in this sequence?

7, the 8th number failed

is there a sequence longer than one you have discovered?

13 numbers long: 6947,9173,11399,18077,44789,178349,979709,6589229,51465389,455350829,4494205229 48921603629,582050384429. Haven't proven if this is the longest sequence or not...

Is there a math equation for this?

Start with your first prime, A. Then B is A+X where X is a multiple of 2. From this, we know that C=A+2X, D=A+5X, E=A+17X... where the multiplier on X is https://oeis.org/A014288


arbitrahj and Paul Panzer have already provided great analysis of this problem.

I would like to demonstrate that

It is possible to find arbitrarily long sequences of primes which satisfy this property (there is no longest sequence). To show this, I need a small lemma and a big theorem.


For any positive integers $a_0$ and $d$, I can generate a sequence of positive integers $a_0, a_1, a_2, \ldots$ such that $a_1 = a_0+d$ and for $n \geq 1$, $a_n$ is the average of $a_0, a_1, \ldots a_{n+1}$.
Furthermore for each $n$, $$a_n = a_0 + b_n d$$ where $b_n$ is an integer.

This has already essentially been shown by arbitrahj and Paul Panzer in their answers but to convince yourself, we can use Paul's difference of two consecutive equations to get $$a_{n+1} = (n+2)a_n - (n+1)a_{n-1}$$ and it's a very easy induction argument from there.


The very big theorem I need is the Green-Tao Theorem which states that the sequence of prime numbers contains arbitrarily long arithmetic progressions.

Putting these together

Suppose we wish to find a sequence of prime numbers of length $N$, with elements $a_0, a_1, \ldots, a_{N-1}$, which satisfies the property that $a_n$ is the average of the numbers $a_0, \ldots, a_{n+1}$ for each $1 \leq n\leq N-2$. (henceforth termed the averaging property)

By the lemma, any sequence of the form $a_0, \,\,a_0 + b_1d, \,\,a_0+b_2d,\ldots, a_0+b_{N-1}d$ will satisfy the averaging property for some specific integer values $b_1, b_2, \ldots, b_{N-1}$ and arbitrary $d$.

Now let $b_{\min} = \min\{0,b_1,\ldots,b_{N-1}\}$ and $b_{\max} = \max\{0,b_1,\ldots,b_{N-1}\}$.
Then by the theorem, there exists integers $A_0$ and $D$ such that each of the elements in the arithmetic progression $$A_0 + b_{\min}D, A_0 + (b_{\min}+1)D, A_0 + (b_{\min}+2)D, \ldots , A_0 + (b_{\max}) D$$ is prime.

Finally, setting $a_0 = A_0$ and $d=D$, we see that we have constructed a sequence $a_0, a_1, \ldots a_{N-1}$ of prime numbers which satisfy the averaging property.

  • 1
    $\begingroup$ Nice one! Funnily enough I stumbled upon the Green-Tao theorem literally a few minutes ago for completely unrelated reasons. $\endgroup$ Commented Jan 30, 2021 at 18:14
  • $\begingroup$ Very nice analysis @hexomino. And thanks to Paul Panzer and arbitraz for clarifying. I loved it! $\endgroup$
    – DrD
    Commented Jan 30, 2021 at 19:24
  • $\begingroup$ bows to the master Awesome, @hexomino! It "felt" open-ended but I had no idea where to start proving it! $\endgroup$
    – arbitrahj
    Commented Jan 31, 2021 at 3:19

Partial answer, heuristic argument that it is plausible to get reasonably long sequences like this 10-prime example:

89 101 113 149 293 1,013 5,333 35,573 277,493 2,454,773

Let us rename the sequence elements for convenience: p_1,p_2,p_3 etc. Then (n+1) x p_n = p_1 + p_2 + ... + p_{n+1} for n>=2. Subtracting two consecutive versions of this identity we get (n+1) x p_n - n x p_{n-1} = p_{n+1}
Now define q_n = p_{n+1} - p_n and rewrite n x q_{n-1} = q_n. This holds from n>=3; We can directly check that q_2 = q_1, so in the end we get q_n = q_1 / 2 x n! (note that q_1 / 2 will be an integer, otherwise the sequence stops right at the beginning).
Now recall that q_n was the difference of consecutive elements of our original sequence: therefore, if p_n happens to be a prime > n then we know already that p_{n+1} is not divided by any number up to n, which nicely improves the odds for it to be prime.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.