OFFSET
0,2
LINKS
Wikipedia, Kronecker symbol
FORMULA
a(n) = Sum_{k=0..n} [gcd(k, n) = 1] * n^k, where [] is the Iverson bracket.
MAPLE
MATHEMATICA
A367546[n_]:=If[n==0, 0, Sum[n^k*Boole[CoprimeQ[n, k]], {k, 0, n}]]; Array[A367546, 25, 0] (* Paolo Xausa, Nov 24 2023 *)
PROG
(SageMath)
def a(n):
return sum(abs(kronecker_symbol(n - k, k)) * n^k for k in range(n + 1))
# Alternative: (For Python include 'import math' for math.gcd.)
def a(n):
cop = [int(gcd(k, n) == 1) for k in (0..n)]
return sum(p * n^k for k, p in enumerate(cop))
print([a(n) for n in range(21)])
(PARI) a(n) = sum(k=0, n, n^k*abs(kronecker(n-k, k))); \\ Michel Marcus, Nov 23 2023
(Python)
from math import gcd
def A367546(n): return sum(n**k for k in range(n+1) if gcd(n, k)==1) # Chai Wah Wu, Nov 24 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Peter Luschny, Nov 22 2023
STATUS
approved