TITLE: How to prove $(\phi-1)(\phi-2)...(\phi-p) = \sqrt{5} + p\left(\frac{1}{2}+A\sqrt{5}\right) \bmod p^2$?
QUESTION [8 upvotes]: We consider the solution of $x^2=x+1$ and denote them as $\phi=\frac{1}{2}(1-\sqrt{5}),\bar\phi=\frac{1}{2}(1+\sqrt{5})$.
Suppose $\phi \not\in \mathbb{F}_p$. In other words, $\sqrt{5} \not \in \mathbb{F}_p\Leftrightarrow p = \pm 2 \bmod 5$. Arbitrary element of $\mathbb{F}_p(\phi)$, $a$ and $b$ satisfies $ab=0\Leftrightarrow a=0 \lor b=0$. From Fermat's little theorem and factor theorem,
$$(x-1)(x-2)...(x-p) = x^p -x \bmod p .$$
Then, put $x=\phi$. Since Frobenius map,$x \mapsto x^p$, transfer $\phi$ to the conjugate of itself, $\bar\phi$,
\begin{align}
&(\phi-1)(\phi-2)...(\phi-p) = \bar\phi -\phi \bmod p\mathbb{Z}(\phi) \\
\Leftrightarrow &(\phi-1)(\phi-2)...(\phi-p) = \sqrt{5}\bmod p\mathbb{Z}(\phi)
\end{align}
Then, what about $(\phi-1)(\phi-2)...(\phi-p) \bmod p^2\mathbb{Z}[\phi]$?
Surprisingly, this can be expressed as
$$(\phi-1)(\phi-2)...(\phi-p) = \sqrt{5} + p\left(\frac{1}{2}+A\sqrt{5}\right) \bmod p^2\mathbb{Z}[\phi]$$
empirically (I verify this rule by a code here ideone. $a$ and $b$ of the output corresponds to $a=\frac{1}{2}p$ and $b=1+pA$). Here $\sqrt{5}$ is defined as $1-2\phi$. $\frac{1}{2}$ is the inverse of $2$ at $\bmod p^2\mathbb{Z}$. Such element can be found by extended Euclidean algorithm because $2$ and $p^2$ are coprime to each other. I cannot find the rule for $A$, but everytime the coeffieicnt of $p$ of $\mathbb{F}_p$ is $\frac{1}{2}$ at $\bmod p^2$.
How to prove this rule?
My idea:
Consider the coefficient, $c_i$ of $(x-1)(x-2)...(x-(p-1))(x-p)=\sum_{i=0}^{p-1}c_ix^i$. It seems $c_i \bmod p=0$ for all $i$ and especially, $c_{2i}=0\bmod p^2$ for $2 \leq 2i \leq p-3$ if $p$ is prime. If $\phi$ is in the form, $a\sqrt{5}$, we only need to consider the term $c_0, c_{p-1}$ because other terms are divisible by $p^2$ or in the form $a'\sqrt{5}$.

REPLY [6 votes]: Start with $$(\phi-i)(\phi-(p+1-i))=\phi^2-\phi(p+1)+i(p+1-i)=p(i-\phi)+(1+i-i^2).$$
Using this for $i=1,2,\ldots,(p-1)/2$ we get
$$
\prod_{j=1}^p(\phi-j)=\left(\phi-\frac{p+1}2\right)\prod_{i=1}^{(p-1)/2}\left(p(i-\phi)+(1+i-i^2)\right).
$$
Expand the brackets and take it modulo $p^2\mathbb{Z}[\phi]$. We get 
$$
M:=\left(\phi-\frac{p+1}2\right)\prod_{i=1}^{(p-1)/2}\left(1+i-i^2\right)+p\left(\phi-\frac12\right)\prod_{i=1}^{(p-1)/2}\left(1+i-i^2\right)\sum_{i=1}^{(p-1)/2}\frac{i-\phi}{1+i-i^2}.
$$
Denote $T=\prod_{i=1}^{(p-1)/2}\left(1+i-i^2\right)$. Considering $M$ modulo $p$ we get $-\sqrt{5}T/2$, thus by your calculation of $M$ modulo $p$ we get $T\equiv -2\pmod p$. Next, we should look mod $p$ for
$$
\frac{M-\sqrt{5}}{p}=-\sqrt{5}\frac{T+2}{2p}+T\left(-\frac12-\frac{\sqrt{5}}2\sum_{i=1}^{(p-1)/2}\frac{i-\phi}{1+i-i^2}\right).
$$
And here we should look for ``rational'' part, which must be equal to $\frac12$ modulo $p$. This rational part equals
$$
T\left(-\frac12-\frac54\sum_{i=1}^{(p-1)/2}\frac{1}{1+i-i^2}\right),
$$
and our claim reduces to
$$
\sum_{i=1}^{(p-1)/2}\frac{1}{1+i-i^2}\equiv -\frac15 \pmod p.
$$
This can not be hard and it is not. We have $1+i-i^2=5/4-(i-1/2)^2$. The guys $(i-1/2)^2$ run over the set $\mathcal{R}$ of all non-zero quadratic residues when $i$ goes from 1 to $(p-1)/2$ (indeed, they are quadratic residues for sure, non-zero and mutually distinct: if $(i-1/2)^2=(j-1/2)^2$, then either $i=j$ or $p$ divides $i+j-1$ which can non be in our range). So we should have $\sum_{r\in \mathcal{R}} 1/(5/4-r)=-1/5$. Denote $f(x)=\prod(x-r)=x^{(p-1)/2}-1$. We should prove $\frac{f'(5/4)}{f(5/4)}=-1/5$. This is true: $f(5/4)=-2$, $f'(5/4)=\frac{p-1}2\cdot (-1)\cdot \frac45=\frac25$.