Residues in Fibonacci sequence mod p

108 Views Asked by At

Let $p$ be prime. For a given residue $k \in \mathbb{Z}_{p}$, check, if exist fibonacci number $F_{n}$, such that $F_{n} \equiv k$ mod $p$.

Using the Binet formula, $\frac{\phi^n - \psi^n}{\phi - \psi} \equiv k$ mod $p$, where $\phi = \frac{1+\sqrt{5}}{2}$ and $\psi = \frac{1-\sqrt{5}}{2} = \frac{1}{-\phi}$, we get $\phi^{2n} - k*(\phi - \psi)\phi^n - (-1)^n \equiv 0$ mod p. Let $\phi^n$ be $x$. Then we have two quadratic equations, depending on parity of $n$.

Since $x^2 - k(\phi - \psi)x = (x - \frac{k(\phi - \psi)}{2})^2 - \frac{k^2(\phi - \psi)^2}{4}$, we get $(x - \frac{k(\phi - \psi)}{2})^2 \equiv \frac{k^2(\phi - \psi)^2}{4} + (-1)^n$ mod $p$. Using $\phi - \psi = \sqrt{5}$, this simplifies to some $t^2 \equiv \frac{5}{4}k^2 + (-1)^n$ mod $p$. If $p > 2$, then inverse to $4$ always exist, hence if Legendre symbol $(\frac{\frac{5}{4}k^2 + (-1)^n}{p})$ not equal to $1$ for odd or even $n$, then such $F_{n}$ does not exist.

However, for $p$ = 7, $\{F_{n} \mod{p}\} = 0,1, 1, 2, 3,5, 1, 6, 0, 6, 6, 5, 4, 2, 6, 1$, but for $k = 3,4$ Legendre symbol $(\frac{\frac{5}{4}k^2 + (-1)^n}{7}) = $ $0$ and $-1$ for even and odd $n$ respectively.

Where is a mistake ?