Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #30 May 08 2021 08:35:58
%S 1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,5,1,1,
%T 1,1,1,1,1,3,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,5,1,1,1,1,
%U 1,1,1,3,1,1,1,1,1,1,1,3,4,1,1,1
%N The period of the sequence i^i (mod n) starts from i=a(n).
%H G. C. Greubel, <a href="/A185358/b185358.txt">Table of n, a(n) for n = 1..5000</a>
%H R. Hampel, <a href="https://doi.org/10.4064/ap-1-2-360-366">The length of the shortest period of rests of numbers n^n</a>, Ann. Polon. Math. 1 (1955), 360-366.
%F If n = Product_{pi^ei} then a(n) = Max_{1- pi*(1+floor[-ei/pi])}.
%t a[p_,e_]:=1- p*(1+Floor[-e/p]);a[n_]:=Max@Module[{fa=FactorInteger[n]},Table[a[fa[[i,1]],fa[[i,2]]],{i,1,Length[fa]}]];Table[a[n],{n,1,84}]
%o (Python)
%o from sympy import factorint, floor
%o def a(n):
%o f=factorint(n)
%o return 1 if n==1 else max(1 - i*(1 + (-f[i])//i) for i in f)
%o print([a(n) for n in range(1, 201)]) # _Indranil Ghosh_, Jun 29 2017
%Y Cf. A185359.
%K nonn
%O 1,8
%A _José María Grau Ribas_, Jan 21 2012