A103310 Largest prime primitive root of n that is less than n, or 0 if none exists.
0, 0, 0, 2, 3, 3, 5, 5, 0, 5, 7, 7, 0, 11, 5, 0, 0, 11, 11, 13, 0, 0, 19, 19, 0, 23, 19, 23, 0, 19, 0, 17, 0, 0, 31, 0, 0, 19, 29, 0, 0, 29, 0, 29, 0, 0, 43, 43, 0, 47, 47, 0, 0, 41, 47, 0, 0, 0, 47, 47, 0, 59, 53, 0, 0, 0, 0, 61, 0, 0, 0, 67, 0, 59, 61, 0, 0, 0, 0, 59, 0, 59, 71, 79, 0, 0, 73
Offset: 0
Links
- Robert Israel, Table of n, a(n) for n = 0..10000
- Eric Weisstein's World of Mathematics, Primitive Root.
Programs
-
Maple
hasproot:= proc(n) if n::odd then nops(numtheory:-factorset(n))=1 else padic:-ordp(n,2)=1 and nops(numtheory:-factorset(n/2))=1 fi end proc; hasproot(2):= true: hasproot(4):= true: f:= proc(n) local p,t; if not hasproot(n) then return 0 fi; t:= numtheory:-phi(n); p:= prevprime(n); while not numtheory:-order(p,n)=t do if p = 2 then return 0 fi; p:= prevprime(p); od; p end proc: f(0):= 0: f(1):= 0: f(2):= 0: map(f, [$0..100]); # Robert Israel, Sep 08 2020
-
Mathematica
a[n_] := Module[{R = PrimitiveRootList[n], s}, s = Select[R, # < n && PrimeQ[#]&]; If[s == {}, 0, s[[-1]]]]; Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Feb 01 2023 *)