Skip to content

Provide sum of four squares representation for Mersenne primes other than M_1

License

Notifications You must be signed in to change notification settings

Hermann-SW/Mersenne_primes_sum4squares

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repo provides sum of four squares for Mersenne primes.
All Mersenne primes besides M1 do not have a sum of three squares representation.
Currently sum of four squares are provided for M2..M29 in M.py.
validate.gp and validate.py demonstrate how to access M.py from Pari/GP and Python.

Validation

pi@raspberrypi5:~/Mersenne_primes_sum4squares $ make

time -f %E\\n  gp -q < validate.gp
all asserts OK
0:00.02

time -f %E\\n  python validate.py
all asserts OK
0:00.05

pi@raspberrypi5:~/Mersenne_primes_sum4squares $ 

Table

Mn=2pn-1=a2+b2+c2+d2, #x short for #digits(x)

Sum of 4 squares was computed with Pari/GP script.
The script takes d to be maximal odd number less than sqrt(Mn).
Nothing can be said about numbers a, b and c other than a2+b2+c2=Mn-d2.

With N=Mn-d2 script determined minimal k, such that k*4*N+2*N-1 is prime.
This allows to create a ternary quadratic form by the method from Dirichlet;
which allows to compute a,b and c with N=a2+b2+c2 easily.

Single thread runtime of Pari/GP script on AMD 7950X CPU is reported as t.

Runtimes of current script definitely do not allow to complete table up to M51.

n #Mn #a #b #c #d k t[s] alg
1 1
2 1 1 1 1 1 2 1
3 2 1 1 1 1 2 1
4 3 1 1 1 2 2 1
5 4 2 2 1 2 1 1
6 6 2 2 1 3 2 1
7 6 2 1 1 3 6 1
8 10 3 3 3 5 5 1
9 19 5 4 4 10 6 1
10 27 7 7 7 14 10 1
11 33 8 8 8 17 16 1
12 39 10 10 9 20 4 1
13 157 40 39 39 79 139 1
14 183 46 46 46 92 4 1
15 386 96 97 96 193 93 1
16 664 167 166 166 332 216 1
17 687 172 172 171 344 2 1
18 969 241 242 242 485 155 1
19 1,281 321 320 320 641 553 2
20 1,332 334 333 333 666 45 1
21 2,917 730 729 730 1,459 475 9
22 2,993 748 749 748 1,497 1,330 27
23 3,376 844 844 844 1,688 618 18
24 6,002 1,501 1,501 1,501 3,001 741 82
25 6,533 1,634 1,634 1,634 3,267 3,853 540
26 6,987 1,747 1,747 1,747 3,494 7,570 12616
27 13,395 3,348 3,349 3,349 6,698 6,845 5377
28 25,962 6,491 6,490 6,490 12,981 5,759 23278
29 33,265 8,317 8,316 8,316 16,633 10,667 82982 (200)
30 39,751 19,875 19,875 19,875 19,876 (31G) 315 foursquares.gp
31 65,050 32,525 32,525 32,525 32,525 (31G) 861 "
32 227,832 113,916 113,916 113,916 113,915 (31G) 14198 "
33 258,716
34 378,632
...
50 23,249,425
51 24,862,048
n #Mn #a #b #c #d k t[s] alg

foursquares.gp

foursquares.gp

About

Provide sum of four squares representation for Mersenne primes other than M_1

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages