A079060 Least k such that the least positive primitive root of prime(k) equals prime(n).
2, 4, 9, 20, 117, 88, 64, 43, 326, 1842, 775, 3894, 14401, 9204, 24092, 14837, 57481, 90901, 242495, 260680, 61005, 508929, 1084588, 436307, 1124509, 1824015, 2969632, 2052357, 4006960, 5241202, 10253662, 30802809, 17480124, 73915355, 98931475, 42664033
Offset: 1
Keywords
Links
- David A. Corneth, Table of n, a(n) for n = 1..45
Programs
-
PARI
a(n) = {my(p=prime(n), s=1); while(p!=lift(znprimroot(prime(s))), s++); s; } \\ Modified by Jinyuan Wang, Apr 03 2020
-
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
-
Python
from sympy import nextprime, primitive_root def a(n): k, pk, pn = 1, 2, prime(n) while primitive_root(pk) != pn: k += 1; pk = nextprime(pk) return k print([a(n) for n in range(1, 19)]) # Michael S. Branicky, Feb 13 2023
-
Python
# faster version for segments of sequence from itertools import count, islice from sympy import isprime, nextprime, prime, primepi, primitive_root def agen(startk=1, startn=1): # generator of terms p, vdict, adict, n = prime(startk), dict(), dict(), startn for k in count(startk): v = primitive_root(p) if v not in vdict and isprime(v): vdict[v] = k adict[primepi(v)] = k while n in adict: yield adict[n]; n += 1 p = nextprime(p) print(list(islice(agen(), 18))) # Michael S. Branicky, Feb 14 2023
Extensions
a(17)-a(18) from Jinyuan Wang, Apr 03 2020
a(19)-a(36) from Michael S. Branicky, Feb 14 2023
Comments