Here is the primality test I found for a number $n$ and the algorithm :
Step 1 : Let $n$ an odd number not divisible by $3$ or $5$ and greater than $5$.
Step 2 : Let $k$ an positive integer (here $k = 1$).
Step 3 : Let $a = (k-1)^2 + 3$.
Step 4 : Let $\left(\frac{n}{a}\right)$ denotes the Jacobi Symbol.
Step 5 : While $a = (k-1)^2 + 3$ is even or $\left(\frac{n}{a}\right)\neq1$ or $gcd(n,a+1) \neq 1$, add $1$ to $k$.
Step 6 : Let $B \equiv x^{n-1}$ mod $(n, f_a)$ where $f_a = x^2 - ax - a$
Step 7 : Let $T=x+n-a-1$ and $U=(n+1)/2 \cdot x + 2$
Step 8 : If $B \neq 1$ check if $B = T$ or $B = U$, if it is, return prime, if not, return composite
Step 9 : If $B = 1$ add $1$ to $k$ and redo step 3 to step 8.
Here is a PARI GP Code
k=1;
c(n,k) = {a=(k-1)^2+3;while(a%2!=1||kronecker(n,a)!=1||gcd(n,a+1)!=1,k++;a=(k-1)^2+3);
B=Mod(Mod(x,n),x^2-a*x-a)^(n-1);
T=x+n-a-1;U=((n+1)/2)*x + 2;
if(B!=1, if(B==T || B==U, print(n,",","probably prime"),
print(n,",","composite")));
while(B==1, k++ && c(n,k))}
{for(n=1,10000,
if(n!=1&&n%2==1&&n%5!=0&&n%3!=0,c(n,k)))}
I have checked all primes and composites to $2^{31}$ and all pass the test.
I would like to know if this is only an coincidence or not. And if not, is there a way to prove it ?
nreturns 1 or 0 depending on its asserted primality: pastebin.com/DW9DHUGy $\endgroup$