login
Odd primes p such that there are as many primitive roots (mod p) in the interval [0,p/2] as in the interval [p/2,p].
3

%I #10 Jan 11 2022 22:12:13

%S 5,7,13,17,29,31,37,41,43,53,61,67,73,89,97,101,109,113,137,149,157,

%T 173,181,193,197,229,233,241,257,269,277,281,293,307,313,317,337,349,

%U 353,367,373,389,397,401,409,421,433,449,457,461,487,509,521,541,557,569

%N Odd primes p such that there are as many primitive roots (mod p) in the interval [0,p/2] as in the interval [p/2,p].

%C The sequence contains all the primes of the form 4m+1 (A002144).

%C The sequence also contains some primes of the form 4m+3 (see them in A172490).

%H Robert Israel, <a href="/A172480/b172480.txt">Table of n, a(n) for n = 1..10000</a>

%p filter:= proc(p) local m; uses NumberTheory;

%p if not isprime(p) then return false fi;

%p if p mod 4 = 1 then return true fi;

%p m:= Totient(Totient(p))/2;

%p PrimitiveRoot(p,ith=m+1)=PrimitiveRoot(p,greaterthan=floor(p/2))

%p end proc:

%p select(filter, [seq(i,i=5..1000,2)]); # _Robert Israel_, Nov 23 2019

%t << NumberTheory`NumberTheoryFunctions` m = 2; s = {}; While[m < 10000, m++; p = Prime[m]; If[Mod[p, 4] == 1, s = {s, p}, q = (p - 1)/2; g = PrimitiveRoot[p]; se = Select[Range[p - 1], GCD[ #, p - 1] == 1 &]; e = Length[se]; j = 0; t = 0; While[j < e, j++; h = PowerMod[g, se[[j]], p]; If[h <= q, t = t + 1,] ]; If[e == 2t, s = {s, p},] ] ]; s = Flatten[s]

%Y A002144 is a subsequence.

%Y Cf. A118818, A172490

%K nonn

%O 1,1

%A _Emmanuel Vantieghem_, Feb 04 2010