login
A340806
a(n) = Sum_{k=1..n-1} (k^n mod n).
1
0, 1, 3, 2, 10, 13, 21, 4, 27, 45, 55, 38, 78, 77, 105, 8, 136, 93, 171, 146, 210, 209, 253, 172, 250, 325, 243, 294, 406, 365, 465, 16, 528, 561, 595, 402, 666, 665, 741, 372, 820, 673, 903, 726, 945, 897, 1081, 536, 1029, 1125, 1275, 1170, 1378, 765, 1485
OFFSET
1,3
LINKS
FORMULA
a(n) = n*A010848(n)/2, if n is odd.
a(n) = n*(n-1)/2, if n is both odd and squarefree.
a(p^e) = (1/2)*(p-1)*p^(2*e-1), if p is an odd prime.
a(2^e) = 2^(e-1).
MAPLE
a:= n-> add(k&^n mod n, k=1..n-1):
seq(a(n), n=1..55); # Alois P. Heinz, Feb 13 2021
PROG
(Python)
def a(n):
return sum([pow(k, n, n) for k in range(1, n)])
for n in range(1, 56):
print(a(n), end=', ')
(PARI) a(n) = sum(k=1, n-1, lift(Mod(k, n)^n)); \\ Michel Marcus, Jan 22 2021
KEYWORD
nonn
AUTHOR
Sebastian Karlsson, Jan 22 2021
STATUS
approved