Implementation of functions for "Integer partitions detect the primes" paper

[email protected]
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <[email protected]>
In forum posting
https://www.mersenneforum.org/node/1081249

somebody asked for a PARI/GP implementation of partition functions from

"Integer partitions detect the primes"
William Craig, Jan-Willem van Ittersum, and Ken Ono

Nice to see how forpart() can be used for non-simple stuff.
I implemented functions M1(n), M2(n) and T1(n) for Theorem 1:
https://www.pnas.org/doi/epub/10.1073/pnas.2409417121
T1(n) is >=0 and =0 for n prime.

pi@raspberrypi5:~ $ freq
min=cur=3000000=max
pi@raspberrypi5:~ $ gp -q
? M1(n)=s=0;fordiv(n,d,s+=d);s;
? 
M2(n)=s=0;for(m=1,n,forpart(v=m,if(v[1]<v[2],for(d=1,n\v[1],r=n-d*v[1];if(r%v[2]==0,s+=d*(r\v[2])))),[1,m],[2,2]));s;
? T1(n)=(n^2-3*n+2)*M1(n)-8*M2(n);
?
? T1(7)
0
? T1(8)
270
? T1(9)
192
? T1(10)
504
? T1(11)
0
?

Makes no fun for bigger an as runtime goes up quickly
(on Raspberry Pi5 overclocked with 3GHz):

? #
    timer = 1 (on)
? T1(100)
cpu time = 20 ms, real time = 20 ms.
998694
? T1(1000)
cpu time = 3,007 ms, real time = 3,009 ms.
1185869880
? T1(2000)
cpu time = 13,477 ms, real time = 13,484 ms.
10118024280
? nextprime(2000)
2003
? T1(2003)
cpu time = 13,448 ms, real time = 13,454 ms.
0
?

Regards,

Hermann.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.