login
Smallest nonnegative integer x such that b^(n-1) == b^x (mod n) for all b that are 0 < b < n.
1

%I #14 Nov 09 2022 19:45:20

%S 0,0,0,3,0,1,0,3,2,1,0,3,0,1,2,7,0,5,0,3,2,1,0,3,4,1,8,3,0,1,0,7,2,1,

%T 10,5,0,1,2,3,0,5,0,3,8,1,0,7,6,9,2,3,0,17,14,7,2,1,0,3,0,1,2,15,4,5,

%U 0,3,2,9,0,5,0,1,14,3,16,5,0,7,26,1,0,5,4,1,2,7,0,5,6,3,2,1,22,7,0,13,8

%N Smallest nonnegative integer x such that b^(n-1) == b^x (mod n) for all b that are 0 < b < n.

%C a(n)=0 iff n=1 or n is prime.

%H Gottfried Helms, <a href="/A079327/b079327.txt">Table of n, a(n) for n = 1..1024</a>

%e a(5) = 0, since for all 1 <= b < 5 it is true that b^0 == b^(5-1) (mod 5) (hence 5 is prime).

%e a(9) = 2, since for all 1 <= b < 9 it is true that b^2 == b^(9-1) (mod 9) (hence 9 is composite).

%t a[n_] := For[x=0, True, x++, If[Mod[Range[n-1]^(n-1), n]==Mod[Range[n-1]^x, n], Return[x]]]

%K easy,nonn

%O 1,4

%A _Gottfried Helms_, Feb 13 2003

%E Edited by _Dean Hickerson_, Feb 15 2003