Is there a primality test based on the sum of squares of the first $n$ natural numbers $\sum_{x = 1}^{n} x^2$?

259 Views Asked by At

The Fibonacci and Catalan primality tests are based on the calculation of the congruences of those numbers versus the possible prime $n$ (the rules are different depending on the primality test), and there are pseudoprimes that verify the primality rules in both cases.

It seems that both pseudoprime sets are disjoint, (probably that point is already known) so applying both primality rules over a possible prime n seems to provide a deterministic primality test (I wrote a test here).

Now I was trying to use the following rule based on the sum of squares as a primality rule for $n$ as follows:

$$\sum_{x = 1}^{n-2} x^2 \equiv (n - 1) \pmod n$$

When I run a test, I can find also pseudoprimes verifying that rule, in the same way that there are Fibonacci and Catalan pseudoprimes, and it also provides correct results for true prime numbers as well.

Unfortunately, while the combination of Fibonacci + Catalan seems to provide (at list testing in the range [4, 6000000]) the correct complete set of prime numbers, without pseudoprimes, the combination of a rule based on the sum of the squares plus a Fibonacci or Catalan primality rule generates pseudoprimes, so the pseudoprime sets are not disjoint.

I have been looking for some information about the primality properties of $\sum_{x = 1}^{n}x^2$, but I did not find any reference. I would like to know if there is a primality test already studied based on it, or a paper or any information related with this possibility. Thank you!

1

There are 1 best solutions below

1
On BEST ANSWER

$$ f(n):=\sum_1^{n-2}x^2=\frac{2n^3 - 9n^2 + 13n - 6}{6} $$ and so your test can be evaluated as such: $$\begin{align} f(6m) &= 72m^3 - 54m^2 + 13m - 1 \equiv& m-1 &\pmod{6m}\\ f(6m+1) &= 72m^3 - 18m^2 + m \equiv& -1 &\pmod{6m+1}\\ f(6m+2) &= 72m^3 + 18m^2 + m \equiv& 3m &\pmod{6m+2}\\ f(6m+3) &= 72m^3 + 54m^2 + 13m + 1 \equiv& 4m+1 &\pmod{6m+3}\\ f(6m+4) &= 72m^3 + 90m^2 + 37m + 5 \equiv& 3m+1 &\pmod{6m+4}\\ f(6m+5) &= 72m^3 + 126m^2 + 73m + 14 \equiv& -1 &\pmod{6m+4} \end{align}$$ and so your test boils down to requiring that the number is 1 or 5 mod 6. Indeed, this is a requirement for primes greater than 3, but it's not useful to test it this way.