Created
November 20, 2024 13:18
-
-
Save Hermann-SW/1966963f390dd8f43fb643965f8f1305 to your computer and use it in GitHub Desktop.
Find minimal 3x3 square of distinct primes, with all row/col/diag sums being mersenne prime exponents and total sum prime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
readvec("mpe.gp"); | |
srch(P)={ | |
my(M=oo); | |
my(S=[]); | |
my(used=Vec(0, 9*P[#P])); | |
my(ismpe=Vec(0,mpe[#mpe])); | |
foreach(mpe,p,ismpe[p]=1); | |
foreach(P,a,used[a]=1; | |
foreach(P,b,if(!used[b],used[b]=1; | |
foreach(P,c,if(!used[c]&&ismpe[a+b+c],used[c]=1; | |
foreach(P,d,if(!used[d],used[d]=1; | |
foreach(P,e,if(!used[e]&&ismpe[d+b+e],used[e]=1; | |
foreach(P,f,if(!used[f]&&ismpe[a+e+f],used[f]=1; | |
foreach(P,g,if(!used[g]&&ismpe[f+b+g]&&ismpe[c+d+g],used[g]=1; | |
foreach(P,h,if(!used[h]&&ismpe[a+h+g],used[h]=1; | |
foreach(P,i,if(!used[i]&&ismpe[h+b+i]&&ismpe[f+i+c], | |
if(isprime(a+b+c+d+e+f+g+h+i), | |
if(a+b+c+d+e+f+g+h+i<M,M=a+b+c+d+e+f+g+h+i;S=[a,b,c,d,e,f,g,h,i];); | |
); | |
)); | |
used[h]=0;)); | |
used[g]=0;)); | |
used[f]=0;)); | |
used[e]=0;)); | |
used[d]=0;)); | |
used[c]=0;)); | |
used[b]=0;)); | |
used[a]=0;); | |
S | |
}; | |
s(i)=concat(if(i<10,"_",""),Str(i)); | |
{ | |
m=eval(getenv("m")); | |
[a,b,c,d,e,f,g,h,i]=srch(primes([3,m])); | |
print("{[",a,",",e,",",f,";\n",h,",",b,",",i,";\n",g,",",d,",",c,"];}"); | |
print("\n_________",g+b+f); | |
print("________/"); | |
print(s(a)," ",s(e)," ",s(f)," __",a+e+f); | |
print(s(h)," ",s(b)," ",s(i)," __",h+b+i); | |
print(s(g)," ",s(d)," ",s(c)," __",g+d+c); | |
print("________\\"); | |
print(a+h+g," ",e+b+d," ",f+i+c," ",a+b+c); | |
print("\nsum: ",a+b+c+d+e+f+g+h+i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Read mpe.gp from this gist:
https://gist.github.com/Hermann-SW/f44c3500b8db158eb87ae8c2fd010e21