OFFSET
1,2
COMMENTS
FORMULA
Numbers 1, 2, 4, p^m and 2*p^m have primitive roots for odd primes p and m >=1 natural number.
MAPLE
a306252 := proc(n::integer)
local r;
r := numtheory[primroot](n) ;
if r <> FAIL then
return r ;
else
return -1 ;
end if;
end proc:
A081888 := proc()
local rec, n, lpr ;
rec := -1 ;
for n from 1 do
lpr := a306252(n) ;
if lpr > rec then
printf("%d, \n", n) ;
rec := lpr ;
end if;
end do:
end proc:
A081888() ; # R. J. Mathar, Apr 04 2019
MATHEMATICA
nmax = 10^5;
r[n_] := r[n] = Module[{prl = PrimitiveRootList[n]}, If[prl == {}, -1, prl[[1]]]]; r[1] = 1;
Reap[Module[{rec = -1, n, lpr}, For[n = 1, n <= nmax, n++, lpr = r[n]; If[lpr > rec, Print[n, " ", lpr]; Sow[n]; rec = lpr]]]][[2, 1]] (* Jean-François Alcover, Jun 19 2023, after R. J. Mathar *)
PROG
(Python)
from sympy import primitive_root
from itertools import count, islice
def f(n): r = primitive_root(n); return r if r != None else 0
def agen(r=0): yield from ((m, r:=f(m))[0] for m in count(1) if f(m) > r)
print(list(islice(agen(), 18))) # Michael S. Branicky, Feb 13 2023
CROSSREFS
KEYWORD
nonn,more
AUTHOR
Sven Simon, Mar 30 2003
EXTENSIONS
a(24) from Michael S. Branicky, Feb 20 2023
STATUS
approved