Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Last active April 26, 2024 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hermann-SW/99851025ec0896b5ae50b387c8aacd4e to your computer and use it in GitHub Desktop.
Save Hermann-SW/99851025ec0896b5ae50b387c8aacd4e to your computer and use it in GitHub Desktop.
72 Phi(3,x) primes from t5k.org, and verification of fast determination of sqrt(-1) (mod p)
Phi(n,x)=polcyclo(n,x);
{
P=[
-516693^1048576, -465859^1048576, -123447^524288, -143332^393216,
-844833^262144, -712012^262144, -558640^196608, -237804^196608, 93606^177147,
55599^177147, -1082083^131072, -843575^131072, -362978^131072, -192098^131072,
-1202113^98304, -1110815^98304, -700219^98304, -660955^98304, -535386^98304,
-406515^98304, -107970^98304, -62721^98304, -1538654^65536, -1456746^65536,
-1427604^65536, -1395583^65536, -1181782^65536, -1147980^65536, -984522^65536,
-883969^65536, -872989^65536, -862325^65536, -861088^65536, -806883^65536,
-770202^65536, -757576^65536, -731582^65536, -682504^65536, -605347^65536,
-340594^65536, -329886^65536, -242079^65536, -180139^65536, -16159^78732,
-96873^65536, -1449889^49152, -1373894^49152, -1316236^49152, -1310544^49152,
-1249158^49152, -1109580^49152, -1020993^49152, -965206^49152, 94259^59049,
-889529^49152, -872232^49152, -747624^49152, -731896^49152, -628716^49152,
-590826^49152, -561180^49152, -544951^49152, -533612^49152, -996094234^4096,
-895721531^4096, -795507696^4096, -691595760^4096, -647020826^4096,
-629813654^4096, -504983334^4096, -314305725^4096, -184534086^4096
];
}
##
print(#P);
{
foreach(P,e,
p=Phi(3,e);
if(e<0,s=sqrtint(-e)^3;print1(s^2%p==p-1),print1("_"))
);
}
##
@Hermann-SW
Copy link
Author

Hermann-SW commented Mar 1, 2024

hermann@7950x:~$ gp -q < Phi3.gp 
  ***   last result: cpu time 229 ms, real time 238 ms.
72
11111111__1111111111111111111111111111111111111111111_111111111111111111
  ***   last result: cpu time 2,820 ms, real time 2,855 ms.
hermann@7950x:~$

@Hermann-SW
Copy link
Author

Hermann-SW commented Apr 26, 2024

Computing sqrt(-1) (mod p) for p=polcyclo(3,be) works if and only if be is a negative square number.
p does not need to be prime:
https://www.mersenneforum.org/showthread.php?p=655817#post655817

? for(be=-100,-1,p=polcyclo(3,be);s=sqrtint(-be)^3;if(s^2%p==p-1,print(be," ",p," ",s," ",isprime(p))))
-100 9901 1000 1
-81 6481 729 1
-64 4033 512 0
-49 2353 343 0
-36 1261 216 0
-25 601 125 1
-16 241 64 1
-9 73 27 1
-4 13 8 1
-1 1 1 0
?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment