I found formula below$$p_n=6\left \lfloor \frac{p_n}{6}+\frac{1}{2} \right \rfloor+\left ( -1 \right )^\left \lfloor \frac{p_n}{3} \right \rfloor$$ for $n>2$, $p_n$ is prime number sequence.

Can anyone prove this formula?

  • 5
    $\begingroup$ This is just a question of noting that $p_n \equiv 1$ or $5$ (mod $6$). $\endgroup$ Dec 30, 2011 at 12:18
  • 2
    $\begingroup$ The correct answer to your question seems to be "yes". ;-) $\endgroup$ Dec 30, 2011 at 15:41

2 Answers 2


For $n>2$ the prime $p_n$ is greater than $3$, so it must be of the form $6k+1$ or $6k+5$. If $p_n=6k+1$, then $$6\left\lfloor \frac{p_n}6+\frac12\right\rfloor= 6\left\lfloor k+\frac16+\frac12\right\rfloor=6k\;,$$ and $$\left\lfloor\frac{p_n}3\right\rfloor=\left\lfloor\frac{6k+1}3\right\rfloor=2k\;,$$ so $$6\left\lfloor\frac{p_n}6+\frac12\right\rfloor+(-1)^{\left\lfloor\frac{p_n}3\right\rfloor}=6k+(-1)^{2k}=6k+1=p_n\;.$$

If $p_n=6k+5$, then $$6\left\lfloor \frac{p_n}6+\frac12\right\rfloor= 6\left\lfloor k+\frac56+\frac12\right\rfloor=6(k+1)\;,$$ and $$\left\lfloor\frac{p_n}3\right\rfloor=\left\lfloor\frac{6k+5}3\right\rfloor=2k+1\;,$$ so $$6\left\lfloor\frac{p_n}6+\frac12\right\rfloor+(-1)^{\left\lfloor\frac{p_n}3\right\rfloor}=6(k+1)+(-1)^{2k+1}=6(k+1)-1=6k+5=p_n\;.$$

  • $\begingroup$ OMG This is very fast.. I was struck dumb at this problem. Thank you $\endgroup$
    – chimpanzee
    Dec 30, 2011 at 12:29

Both this formula for $p_n$ as well as this one:

$$p_n=2\Biggl(\Bigl\lfloor \frac{p_n+1}{8}\Bigr\rfloor+\Bigl\lfloor \frac{p_n+3}{8} \Bigr\rfloor+\Bigl\lfloor \frac{p_n+5}{8} \Bigr\rfloor+\Bigl\lfloor \frac{p_n+7}{8} \Bigr\rfloor\Biggr)-1+\delta(n,1) \quad\quad\quad\quad\quad\quad(0)$$

Are proven in effect by the proving of Hermite's Identity:

(see wiki for such a proof)

$$\lfloor nx\rfloor =\sum_{i=1}^n\,\left\lfloor x+\frac{i-1}{n}\right\rfloor\text{ for all }x\in\mathbb{R}\text{ and }n\in\mathbb{Z}_{>0}\,.$$

You can also state both as follows in terms of a singular piece wise delta function which involve the most relevant congruence relations here,which in combination with the original answer that has been provided and an understanding of the proof of Hermite's Identity, I feel might be able give this post a little more depth to the reader's understanding of the content:

Correction pending me being bothered and not broke

$\frac{1}{2}\Biggl(6\Bigl\lfloor \frac{n}{6}+\frac{1}{2} \Bigr\rfloor+(-1)^{\Bigl\lfloor \frac{n}{3} \Bigr\rfloor}-2\Bigl(\Bigl\lfloor \frac{n+1}{8} \Bigr\rfloor+\Bigl\lfloor \frac{n+3}{8} \Bigr\rfloor+\Bigl\lfloor \frac{n+5}{8} \Bigr\rfloor+\Bigl\lfloor \frac{n+7}{8} \Bigr\rfloor\Bigr)+1\Biggr)=\cases{1&$n\equiv{\{0,3,6}\}(\mod6)$\cr 0&$n\equiv{\{1,2,5}\} (\mod 6)$\cr} $ Error due me being broke and not bothered anymore

For the actual application of Hermite's identity to rigorously prove the formula of this post, a very well done example has already been provided in the answer for a question I asked myself recently, which I will link here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .