// This code computes primitive elements -- precomputed for some primes // Copyright, Michael Monagan, March 2020. #include #define LONG long long int int ifactor64s( LONG n, LONG *P ) { // return k factors in P[0], P[1], ..., P[k-1] int k; LONG p,q,r; p = 2; k = 0; while( n>1 ) { q = n/p; r = n-p*q; if( r==0 ) P[k++] = p; while( r==0 ) { n = q; q = n/p; r = n-q*p; } if( p==2 ) p = 3; else p += 2; if( n>1 && p*p>n ) { P[k++] = n; n = 1; } } return k; } LONG powmod64s( LONG a, LONG n, LONG p ); int isprimitive64s( LONG a, LONG *P, int n, LONG p ) { int k; for( k=0; k