# Some heuristics about the Pisano Period, primes and Fibonacci primes. What reasons are behind them?

I started to read about the Pisano Period, $\pi(n)$, applied to the classic Fibonacci sequence and made some simple tests looking for possible properties of the sequence. I have observed the following ones, tested for the first 10000 terms:

1. $\pi(n)=n-1 \implies n\in\Bbb P$

2. $\pi(n)=(n-1)/2 \implies n\in\Bbb P$

3. $\pi(n)=(n+1)\cdot 2 \implies n\in\Bbb P$

4. $k \gt 5\ ,\ F_k \in \Bbb P \implies \pi(F_k)/4=k$

I do not understand the reasons for the results: points $1\sim3$ would work as a primality test, but it does not detect all the possible primes, only a subset of them, e.g. $\{2, 5, 47, 107, 113, 139,\ldots\}$ do not comply with points $1\sim3$ and are not detected. And specially the last point, if the test is correct, would mean that the Pisano period of a Fibonacci prime is exactly four times the index of the Fibonacci prime in the Fibonacci sequence when the index is greater than $5$ (being $F_5=5$) . For instance: $\pi(1597)= 68$ and $\frac{68}{4}=17$ which is exactly the index of $1597$ in the Fibonacci sequence, $F_{17}=1597$.

I would like to ask the following questions:

(a) Is there a counterexample? Initially I think the tests are correct, but I am not very sure about point 4. If somebody could confirm would be great.

(b) What are the reasons behind the observations? I guess that it is related with the relationship of the Pisano periods and the divisibility of the Fibonacci numbers by prime numbers.

(c) If the observations are correct, would we find pseudoprimes in the lists of primes detected by the rules $1 \sim 3$?

Probably the reasons behind the observations (if no counterexamples are found) are based on some simple properties of the Fibonacci numbers, but I do not see it clearly. Any hints or ideas are very welcomed. Thank you!

Update 2016/01/14: I have modified the information about point $4$ just to keep the correct information. After testing again, there are other $n$'s complying with $4$ and not being Fibonacci primes, so I have rewritten the statement: the Pisano period of a Fibonacci prime seems to be four times its Fibonacci index (position in the Fibonacci sequence) but that also holds for some other numbers.

Addendum: Below is the graph $n \rightarrow \pi(n)$ including the fist $100$ numbers showing the rules $1\sim3$. Rule $1$: $\color{red}{Red}$, Rule $2$: $\color{blue}{Blue}$, Rule $3$: $\color{green}{Green}$ (click to widen). • At least items 1-3 are related to Binet's formula for $F_n=(\varphi^n-\overline{\varphi}^n)/\sqrt5$, where $\varphi=(1+\sqrt5)/2$ is the golden ratio and $\overline{\varphi}=-1/\varphi=(1-\sqrt5)/2$ is its conjugate. For example, if $n$ is an odd number such that $5$ is a quadratic residue modulo $n$, and $\varphi$ has order $n-1$ modulo $n$, then clearly $n$ must be a prime. Unfortunately I don't see right away why the Pisano period would need to be exactly equal to order of $\varphi$ modulo $n$. In other words, my logic flows in the wrong direction here. – Jyrki Lahtonen Jan 13 '16 at 6:21
• (cont'd) Item 2 is probably related to both $5$ and $\varphi$ being quadratic residues modulo $n$. Item 3 is related to the case of $5$ being a quadratic non-residue modulo a prime $p$, when $\varphi^p\equiv\overline{\varphi}\pmod p$ and consequently $\varphi$ has order $2(p+1)$ in $\Bbb{F}_{p^2}$. Can't say anything about item 4. – Jyrki Lahtonen Jan 13 '16 at 6:25
• Thanks, but I need to work on the direction of the flow first. I thank that with a bit more effort and/or insight somebody (possible me, more likely somebody else) can say something definite. The above was all half-baked, which is why it should stay as a comment. – Jyrki Lahtonen Jan 13 '16 at 6:34
• @Jyrki: I don't believe your first statement (if $5$ is a QR and $\varphi$ has order $n-1$ then $n$ is prime) is true. This is analogous to asserting that Fermat pseudoprimes are prime. – Qiaochu Yuan Jan 13 '16 at 18:12
• Ah sorry, it's a stronger condition. Hmm. – Qiaochu Yuan Jan 14 '16 at 3:41

I think first three statements are all false. Numbers with these properties are analogous to Fermat pseudoprimes, and in particular there's no reason to expect that they should in fact always be prime, although counterexamples might be quite large.

Using Binet's formula as in Jyrki's comments, you can prove results like the following. Let $p \neq 5$ be a prime. We will need the Legendre symbol $\left( \frac{5}{p} \right)$, which is equal to $1$ if $p \equiv 1, 4 \bmod 5$ and $-1$ if $p \equiv 2, 3 \bmod 5$. For reasons that will become apparent I'll write $F_n$ as $F(n)$.

First,

$$F(p) \equiv \left( \frac{5}{p} \right) \bmod p.$$

Next,

$$F \left( p - \left( \frac{5}{p} \right) \right) \equiv 0 \bmod p.$$

These are the two basic results, analogous to Fermat's little theorem. Together they allow you to bound the Pisano period of primes as follows: if $\left( \frac{5}{p} \right) = 1$, then the Pisano period divides $p - 1$. If $\left( \frac{5}{p} \right) = -1$, then the Pisano period divides $2(p + 1)$.

This is a partial explanation of your first observation. For your second two observations we have the following slightly harder result. If $p \equiv 1 \bmod 4$, then

$$F \left( \frac{p - \left( \frac{5}{p} \right)}{2} \right) \equiv 0 \bmod p.$$

• @QuiaochuYuan Thanks for your time and explanation, I will read more about the Legendre symbol to understand your kind explanation. My first thought was that probably the Fibonacci pseudoprimes (those attached to the "classic" primality test over the Fibonacci numbers) would appear if the $1$~$3$ statements are applied. The fourth I understand that seems very hard to verify. – iadvd Jan 13 '16 at 23:40
• I will put apart the fourth statement in a different question – iadvd Jan 13 '16 at 23:58
• sorry I did not notice before, statement (1) was included at the OEIS sequence at 2002 by Benoit Cloitre (in the formula section not in the comments, that is why I did not noticed it) oeis.org/A001175 indeed there is a sequence related with them oeis.org/A003147. That does not mean anything, but just in case of doubt, it seems that it was noticed before. There is no reference for my other $2$~$4$ statements though. – iadvd Jan 14 '16 at 4:25

I think it is not hard to prove that. In fact, only by using the definition. For example, if $$\pi(n)=n-1$$ and $$n=4k+1$$, then $$4k+1$$ divides $$F_{4k}$$ and $$4k+1$$ divides $$F_{4k+1}-1=F_{2k+1}L_{2k-1}$$. Let $$p$$ be a prime dividing $$4k+1$$, then $$\pi(p)\mid 4k$$ and $$\pi(p)\mid 2k+1$$ (without loss of generality, since $$\gcd(F_{2k+1},L_{2k-1})=1$$). Thus, $$pi(p)\mid 2(2k+1)-4k=2$$. Thus, $$\pi(p)=1$$ or $$2$$ and the conclusion follows.