OFFSET
1,1
COMMENTS
a(n) <= A023049(n).
a(n) = 0 iff n is a square > 1.
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(6) = 11 because 6 is a primitive root mod 11 and no number from 7 to 10 has 6 as a primitive root.
MAPLE
N:= 1000: # to allow values <= N
P:= select(isprime, {seq(i, i=3..N, 2)}):
Cands:= map(proc(t) local i; (seq(t^i, i=1..ilog[t](N)), seq(2*t^i, i=1..ilog[t](N/2))) end proc, P):
Cands:= sort(convert({4} union Cands, list)):
Phis:= map(numtheory:-phi, Cands):
f:= proc(n)
local k0, k;
if issqr(n) then return -1 fi;
k0:= ListTools:-BinaryPlace(Cands, n)+1;
for k from k0 do
if igcd(Cands[k], n) = 1 and numtheory:-order(n, Cands[k]) = Phis[k] then return Cands[k] fi
od
end proc:
f(1):= 2:
map(f, [$1..200]);
CROSSREFS
KEYWORD
sign
AUTHOR
Robert Israel, Nov 11 2024
STATUS
approved