login
A319813
a(n) is the smallest k such that k^n + 1 is divisible by n, or 0 if no such a exists.
1
1, 1, 2, 0, 4, 0, 6, 0, 2, 3, 10, 0, 12, 0, 14, 0, 16, 0, 18, 0, 5, 0, 22, 0, 4, 5, 2, 0, 28, 0, 30, 0, 32, 13, 34, 0, 36, 0, 17, 0, 40, 0, 42, 0, 14, 0, 46, 0, 6, 3, 50, 0, 52, 0, 19, 0, 8, 17, 58, 0, 60, 0, 5, 0, 64, 0, 66, 0, 68, 0, 70, 0, 72, 31, 14, 0, 76
OFFSET
1,3
COMMENTS
a(n) = 0 iff n is even and -1 is not a square modulo n, that is, n is even and not in A008784. For other n > 2, 2 <= a(n) <= n - 1.
a(p) = p - 1 for primes p. For composite n, a(n) = n - 1 iff gcd(n, phi(n)) = 1, that is, n is in A050384.
a(A006521(n)) = 2.
LINKS
FORMULA
For n = 9, k^9 + 1 is divisible by 9 implies k == 2 (mod 3), so a(9) = 2.
For n = 10, k^10 + 1 is divisible by 10 implies k == 3, 7 (mod 10), so a(10) = 3.
For n = 34, k^34 + 1 is divisible by 34 implies k == 13, 21 (mod 34), so a(34) = 13.
MAPLE
f:= proc(n) local a, S;
S:= {msolve(a^n+1, n)};
if S = {} then 0 else min(map(t -> rhs(op(t)), S)) fi
end proc:
f(1):= 1:
map(f, [$1..100]); # Robert Israel, May 26 2026
PROG
(PARI) a(n) = if(!(n%2)&&!issquare(Mod(-1, n)), 0, my(i=1); while(Mod(i, n)^n!=n-1, i++); i)
CROSSREFS
Cf. A074792 (a^n - 1 instead of a^n + 1).
Cf. also A006521, A008784, A050384.
Sequence in context: A320582 A119690 A166260 * A366562 A071648 A001613
KEYWORD
nonn
AUTHOR
Jianing Song, Sep 28 2018
EXTENSIONS
Corrected by Robert Israel, May 26 2026
STATUS
approved