## Other

drummers-lowrise

Message boards : Wieferich and Wall-Sun-Sun Prime Search : Check a WW find with PARI/GP

 Subscribe SortOldest firstNewest firstHighest rated posts first
Author Message
Message 145728 - Posted: 28 Nov 2020 | 13:18:49 UTC

I am repeating myself here, because I have posted these PARI functions before (in the old days in the Project Staging Area subforum), but now that we have a dedicated WW subforum, I thought I would create a thread.

You can test your Wall-Sun-Sun/Wieferich find or near-find easily and very quickly with PARI/GP. Here are some methods:

checkwss(p) = { if(!isprime(p)||p<=5,return("no, p is not a prime greater than 5")); index = p-kronecker(p,5); result = Mod([1,1;1,0],p^2)^(index-1); result = centerlift(result[1,1])/p; Strprintf("%d is a WallSunSun special instance (+0 %+d p)", p, result) } checkwieferich(p) = { if(!isprime(p)||p==2,return("no, p is not an odd prime")); plusOrMinus = kronecker(2,p); result = centerlift(Mod(2,p^2)^((p-1)/2)); result = (result-plusOrMinus)/p; Strprintf("%d is a Wieferich special instance (%+d %+d p)", p, plusOrMinus, result) } checkww(p) = print(checkwss(p));print(checkwieferich(p))

The functions declare all primes special instances, but you can check for yourself if the A value in the parenthesis is small. For example checkww(597076280277725011) gives
597076280277725011 is a WallSunSun special instance (+0 -200675094101863100 p) 597076280277725011 is a Wieferich special instance (-1 +865 p)
from which you see that as a Wall-Sun-Sun it is not "near", but with Wieferich, it is "near" (+865 is small).

Of course, if you want the A value as an integer (not inside some formatted text string), that part is easy to extract:
wssA(p) = { if(!isprime(p)||p<=5,return("no, p is not a prime greater than 5")); index = p-kronecker(p,5); result = Mod([1,1;1,0],p^2)^(index-1); centerlift(result[1,1])/p; } wieferichA(p) = { if(!isprime(p)||p==2,return("no, p is not an odd prime")); plusOrMinus = kronecker(2,p); result = centerlift(Mod(2,p^2)^((p-1)/2)); (result-plusOrMinus)/p; }

Note, PrimeGrid's WW search is about small primes, up to 19 digits. So it is instantaneous to check one such prime with the above functions.

If you want to use these function with titanic prime, you should remove the first line in all the multiline functions (the line that checks the sanity of the argument p). That is because isprime is slow; you should check primality with another tool if the candidates are huge.

/JeppeSN

Message boards : Wieferich and Wall-Sun-Sun Prime Search : Check a WW find with PARI/GP