OFFSET
2,1
COMMENTS
a(n) = 0 when n is not squarefree. The reason is obvious when n is a perfect square, cube or higher power. Otherwise, n = (p^r)(q^s), where p is some prime, gcd(p, q) = 1, r > 1, s != r; then when k > floor(log_p(n)), p^k mod n is always a multiple of p^2 and thus p doesn't occur again (e.g., for n = 72, the powers of 2 mod 72 are 1, 2, 4, 8, 16, 32, 64, 56, 40, 8, ... in fact, always multiples of 2^3 past 4).
Fermat's little theorem suggests that a(n) = n when n is prime, since then clearly i^(n - 1) = 1 mod n.
Often, but not always, a(n) = abs(mu(n))(phi(n) + 1), where mu(n) is the Möbius function and phi(n) is Euler's totient function. This is the case when phi(n) = psi(n), where psi(n) is the reduced totient function (or Carmichael lambda function). Thus when n is squarefree it's not guaranteed that a(n) is a divisor of n.
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 2..10000
FORMULA
a(n) = abs(mu(n))(psi(n) + 1), where mu(n) is the Moebius function and psi(n) is the reduced totient function.
a(n) = A002322(n) + 1 if n squarefree, otherwise a(n) = 0. - Joerg Arndt, Jan 22 2013
EXAMPLE
a(6) = 3 because in the powers modulo 6
0 1 2 3 4 5
0 1 4 3 4 1
0 1 2 3 4 5
we see that at k = 1 and k = 3 each i^k = i mod 6.
a(7) = 7 because in the powers modulo 7
0 1 2 3 4 5 6
0 1 4 2 2 4 1
0 1 1 6 1 6 6
0 1 2 4 4 2 1
0 1 4 5 2 3 6
0 1 1 1 1 1 1
0 1 2 3 4 5 6
we see that at k = 1 and k = 7 each i^k = i mod 7.
a(8) = 0 because in the powers modulo 8, 4^k zeros out at k = 2, thus preventing the row 0 1 2 3 4 5 6 7 from occurring at any position other than k = 1.
MATHEMATICA
Table[Abs[MoebiusMu[n]](CarmichaelLambda[n] + 1), {n, 2, 100}]
PROG
(PARI) a(n)=if(issquarefree(n), lcm(znstar(n)[2])+1, 0) \\ Charles R Greathouse IV, Jan 17 2013
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Alonso del Arte, Jan 07 2013
STATUS
approved