# Can anyone prove this formula?

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?

-
This is just a question of noting that $p_n \equiv 1$ or $5$ (mod $6$). – Geoff Robinson Dec 30 '11 at 12:18
The correct answer to your question seems to be "yes". ;-) – Hans Lundmark Dec 30 '11 at 15:41

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\;.$$