hermann on Wed, 27 Nov 2024 22:54:23 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

25! with early aborts: 31ms to find minimal 5x5 square of distinct primes with sum of rows/cols/diags prime and total sum prime(!)


I always get surprised how easy things can be done with PARI/GP.

My first dynamic program in PARI/GP with sets (subset sum with knowing all possible subset sizes):
https://www.mersenneforum.org/node/1055343?p=1062012#post1062012

And how fast GP is.

The gist is my forst ever code with 25 nester for loops on variables a..y, more info:
https://www.mersenneforum.org/node/1055343?p=1062097#post1062097

pi@raspberrypi5:~/PrimeSquares $ time gp -q < sum25f.gp
{[3,5,7,11,17;
67,41,43,13,47;
37,53,19,59,113;
31,23,71,61,97;
29,89,83,79,73];}

real	0m0.031s
user	0m0.028s
sys	0m0.004s
pi@raspberrypi5:~/PrimeSquares $

pi@raspberrypi5:~/PrimeSquares $ cat > 1171.gp
{[3,5,7,11,17;
67,41,43,13,47;
37,53,19,59,113;
31,23,71,61,97;
29,89,83,79,73];}
pi@raspberrypi5:~/PrimeSquares $ ps=1171.gp gp -q < validate.gp
1171.gp, sum: 1171, validated
pi@raspberrypi5:~/PrimeSquares $


Regards,

Hermann.