Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #25 Feb 16 2023 05:23:04
%S 2,4,9,20,117,88,64,43,326,1842,775,3894,14401,9204,24092,14837,57481,
%T 90901,242495,260680,61005,508929,1084588,436307,1124509,1824015,
%U 2969632,2052357,4006960,5241202,10253662,30802809,17480124,73915355,98931475,42664033
%N Least k such that the least positive primitive root of prime(k) equals prime(n).
%C a(49) = 1247136427. For n > 45, a(n) > 1.5*10^9 except n = 49. - _David A. Corneth_, Feb 15 2023
%H David A. Corneth, <a href="/A079060/b079060.txt">Table of n, a(n) for n = 1..45</a>
%o (PARI) a(n) = {my(p=prime(n), s=1); while(p!=lift(znprimroot(prime(s))), s++); s; } \\ Modified by _Jinyuan Wang_, Apr 03 2020
%o (PARI) upto(u, {maxn = 100}) = { my(t = 1, m = Map(), res = []); forprime(p = 2, oo, mapput(m, p, t); t++; if(t > maxn, break ) ); t = 1; u = prime(u); forprime(p = 2, u, c = lift(znprimroot(p)); if(mapisdefined(m, c), ind = mapget(m, c); if(ind > #res, res = concat(res, vector(ind - #res)) ); if(res[ind] == 0, res[ind] = t; ) ); t++ ); res } \\ _David A. Corneth_, Feb 15 2023
%o (Python)
%o from sympy import nextprime, primitive_root
%o def a(n):
%o k, pk, pn = 1, 2, prime(n)
%o while primitive_root(pk) != pn: k += 1; pk = nextprime(pk)
%o return k
%o print([a(n) for n in range(1, 19)]) # _Michael S. Branicky_, Feb 13 2023
%o (Python) # faster version for segments of sequence
%o from itertools import count, islice
%o from sympy import isprime, nextprime, prime, primepi, primitive_root
%o def agen(startk=1, startn=1): # generator of terms
%o p, vdict, adict, n = prime(startk), dict(), dict(), startn
%o for k in count(startk):
%o v = primitive_root(p)
%o if v not in vdict and isprime(v):
%o vdict[v] = k
%o adict[primepi(v)] = k
%o while n in adict: yield adict[n]; n += 1
%o p = nextprime(p)
%o print(list(islice(agen(), 18))) # _Michael S. Branicky_, Feb 14 2023
%Y Cf. A001918, A023048, A066529.
%K nonn
%O 1,1
%A _Benoit Cloitre_, Feb 02 2003
%E a(17)-a(18) from _Jinyuan Wang_, Apr 03 2020
%E a(19)-a(36) from _Michael S. Branicky_, Feb 14 2023