A046145 Smallest primitive root modulo n, or 0 if no root exists.
0, 0, 1, 2, 3, 2, 5, 3, 0, 2, 3, 2, 0, 2, 3, 0, 0, 3, 5, 2, 0, 0, 7, 5, 0, 2, 7, 2, 0, 2, 0, 3, 0, 0, 3, 0, 0, 2, 3, 0, 0, 6, 0, 3, 0, 0, 5, 5, 0, 3, 3, 0, 0, 2, 5, 0, 0, 0, 3, 2, 0, 2, 3, 0, 0, 0, 0, 2, 0, 0, 0, 7, 0, 5, 5, 0, 0, 0, 0, 3, 0, 2, 7, 2, 0, 0, 3, 0, 0, 3, 0, 0, 0, 0, 5, 0, 0, 5, 3, 0, 0
Offset: 0
Links
- T. D. Noe, Table of n, a(n) for n = 0..10000
- Pēteris K. Siliņš, Cross ratios for finite field geometries, Bachelor's Thesis, Univ. Groningen (Netherlands, 2024). See p. 17.
- Eric Weisstein's World of Mathematics, Primitive Root.
Crossrefs
Programs
-
Maple
A046145 := proc(n) if n <=1 then 0; else pr := numtheory[primroot](n) ; if pr = FAIL then return 0 ; else return pr ; end if; end if; end proc: seq(A046145(n),n=0..110) ; # R. J. Mathar, Jul 08 2010
-
Mathematica
smallestPrimitiveRoot[n_ /; n <= 1] = 0; smallestPrimitiveRoot[n_] := Block[{pr = PrimitiveRoot[n], g}, If[! NumericQ[pr], g = 0, g = 1; While[g <= pr, If[ CoprimeQ[g, n] && MultiplicativeOrder[g, n] == EulerPhi[n], Break[]]; g++]]; g]; smallestPrimitiveRoot /@ Range[0, 100] (* Jean-François Alcover, Feb 15 2012 *) f[n_] := Block[{pr = PrimitiveRootList[n]}, If[pr == {}, 0, pr[[1]]]]; Array[f, 105, 0] (* v10.0 Robert G. Wilson v, Nov 04 2014 *)
-
PARI
{ A046145(n) = for(q=1,n-1, if(gcd(q,n)==1 && znorder(Mod(q,n))==eulerphi(n), return(q);)); 0; } /* V. Raman, Nov 22 2012, edited by Max Alekseyev, Apr 20 2017 */
-
Perl
use ntheory ":all"; say "$ ", znprimroot($) || 0 for 0..100; # Dana Jacobsen, Mar 16 2017
Extensions
Initial terms corrected by Harry J. Smith, Jan 27 2005
Comments