login
Smallest multiplicative generator for quadratic residues mod prime(n).
2

%I #25 Dec 23 2021 23:05:16

%S 1,1,4,2,3,4,2,4,2,4,7,3,2,9,2,4,3,4,4,2,6,2,3,5,2,4,2,3,12,9,9,3,2,4,

%T 4,5,3,4,2,4,3,4,2,2,4,2,4,9,3,5,7,2,3,3,9,2,4,2,7,5,6,4,7,2,2,4,5,3,

%U 3,3,9,2,2,3,4,2,4,3,2,2,3,4,5,6,5,3,2,3,4,2,3,2,2,4,5,2,4,2,4,4,4,4,3,2,5,17

%N Smallest multiplicative generator for quadratic residues mod prime(n).

%H Robert Israel, <a href="/A001390/b001390.txt">Table of n, a(n) for n = 1..10000</a>

%p f:= proc(p) local x;

%p for x from 1 do if numtheory:-order(x,p) = (p-1)/2 then return x fi od

%p end proc:

%p f(2):= 1:

%p seq(f(ithprime(n)), n=1..1000); # _Robert Israel_, Jan 14 2016

%t f[p_] := Module[{x}, For[x = 1, True, x++, If[MultiplicativeOrder[x, p] == (p - 1)/2, Return[x]]]];

%t f[2] = 1;

%t f /@ Prime[Range[100]] (* _Jean-François Alcover_, Jul 17 2020, after Maple *)

%Y Cf. A000040.

%K nonn

%O 1,3

%A _N. J. A. Sloane_

%E More terms from _David W. Wilson_, Aug 15 1996

%E Offset changed by _Robert Israel_, Jan 14 2016