Created
February 16, 2026 14:16
-
-
Save Hermann-SW/a14dc268d533b96afbd52b2a9d3c92e8 to your computer and use it in GitHub Desktop.
Parallel determination of primitive root of n-th Euclid prime
This file contains hidden or 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
| check(En, n, phi, g, i)={ | |
| parfor(i=1, n, lift(Mod(g, En)^(phi / prime(i))) == 1, r, if(r, return(0))); | |
| 1 | |
| } | |
| euclid_prime_find_root(n) = { | |
| my(En = vecprod(primes(n)) + 1, phi = En - 1); | |
| for(g=2, En-1, | |
| if(lift(kronecker(g, En))==-1, | |
| if(check(En, n, phi, g, i), return(g)); | |
| ); | |
| ); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Demonstration on 457th Euclid prime,
and demonstration of huge speedup over GP znprimroot() (which has to factor N-1 first)
and sequential seq.gp gist below: