Compositeness test using $S_i=6S_{i-1}-11S_{i-2}+6S_{i-3}$ recurrence relation

72 Views Asked by At

Can you prove or disprove the following claim:

Let $S_i=6S_{i-1}-11S_{i-2}+6S_{i-3}$ with $S_0=0$ , $S_1=1$ , $S_2=1$ . Let $n$ be a natural number greater than $3$, then: $$\text{If } n \text{ is a prime number then } S_{n-1} \equiv 0 \pmod{n}$$

You can run this test here. I have verified this claim for all $n$ up to $100000$ .

I was searching for counterexample using the following PARI/GP code:

rec(m,P,Q,R)={s0=0;s1=1;s2=1;l=3;while(l<=m,s=P*s2+Q*s1+R*s0;s0=s1;s1=s2;s2=s;l++);return(s);}
RPT(n1,n2)={forprime(n=n1,n2,if(Mod(rec(n-1,6,-11,6),n)!=0,print(n);break))}
1

There are 1 best solutions below

0
On BEST ANSWER

Note that the roots of $$x^3 - 6x^2 + 11x - 6 = 0$$ are $1, 2, 3$.

Thus, the general term can be written as $$S_n = A\cdot1^n + B\cdot2^n + C\cdot3^n$$ for some constants $A, B, C$.

(See this for details.)


Using $S_0, S_1, S_2$, we can determine $(A, B, C)$. It turns out to be $(-2, 3, -1)$. That is, $$S_n = -2 + 3\cdot2^n - 3^n.$$


Now, since $n$ is a prime number coprime to $2$ and $3$, we have $$2^{n-1} \equiv 1 \pmod n$$ and $$3^{n-1} \equiv 1 \pmod n.$$ This follows from Fermat's little theorem.

In this case, we have $$S_{n-1} \equiv -2 + 3 - 1 \equiv 0 \pmod n,$$ as desired.


EDIT: Additional observation! We didn't even have to calculate $(A, B, C).$
Once we know that $S_n = A + B\cdot2^n + C\cdot3^n$, Fermat's little theorem would directly give us $$S_{n-1} \equiv A + B +C \equiv S_0 \pmod n.$$ We already have that $S_0 = 0 \equiv 0\pmod n$ and thus, we would be done.