%I
%S 0,0,1,0,1,1,0,1,2,0,1,0,3,0,1,4,2,1,0,1,3,1,4,0,1,1,3,1,0,1,2,4,4,0,
%T 1,4,3,4,5,0,1,4,6,4,3,1,0,1,1,4,2,1,6,0,1,2,5,1,5,1,0,1,4,1,4,4,6,0,
%U 1,1,3,2,6,1,0,1,2,2,1,2,6,0,1,0,3,0,5,0,7
%N Irregular table read by rows: T(n,k) = (k+s)^(k+s) mod n, s = lcm(n, A002322(n)) = A174824(n), 0 <= k <= s  1.
%C A174824(n) is the period of the sequence {k^k mod n}.
%C If n > 1 is factored as Product_{i=1..m} (p_i)^(e_i), then {k^k mod n : k > e} is purely periodic, e = max_{i=1..m} (p_i)*floor((e_i  1)/(p_i)). For n > 1, {k^k mod n : k > 0} is purely periodic iff e_i <= p_i, 1 <= i <= m.
%F T(n,k) = k^k mod n iff: let p be any prime factor of k, then n is not divisible by p^(k+1).
%e Table starts
%e n = 1: 0,
%e n = 2: 0, 1,
%e n = 3: 0, 1, 1, 0, 1, 2,
%e n = 4: 0, 1, 0, 3,
%e n = 5: 0, 1, 4, 2, 1, 0, 1, 3, 1, 4, 0, 1, 1, 3, 1, 0, 1, 2, 4, 4,
%e n = 6: 0, 1, 4, 3, 4, 5,
%e n = 7: 0, 1, 4, 6, 4, 3, 1, 0, 1, 1, 4, 2, 1, 6, 0, 1, 2, 5, 1, 5, 1, 0, 1, 4, 1, 4, 4, 6, 0, 1, 1, 3, 2, 6, 1, 0, 1, 2, 2, 1, 2, 6,
%e n = 8: 0, 1, 0, 3, 0, 5, 0, 7,
%e n = 9: 0, 1, 4, 0, 4, 2, 0, 7, 1, 0, 1, 5, 0, 4, 7, 0, 7, 8,
%e n = 10: 0, 1, 4, 7, 6, 5, 6, 3, 6, 9, 0, 1, 6, 3, 6, 5, 6, 7, 4, 9,
%o (PARI) T(n,k) = my(s=lcm(n, lcm(znstar(n)[2]))); lift(Mod(k+s, n)^(k+s))
%o tabf(nn) = for(n=1, nn, for(k=0, lcm(n, lcm(znstar(n)[2])))1, print1(T(n,k), ", ")); print);
%Y Cf. A000312, A002322, A174824.
%K nonn,tabf
%O 1,9
%A _Jianing Song_, Oct 17 2018
