login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A367546
a(n) = Sum_{k=0..n} n^k * |(n - k | k)|, where (a | b) denotes the Kronecker symbol.
3
0, 2, 2, 12, 68, 780, 7782, 137256, 2130440, 47895390, 1010001010, 28531167060, 743044451340, 25239592216020, 797785000011174, 31147773583410240, 1157442765409226768, 51702516367896047760, 2185932446972586391986, 109912203092239643840220, 5255987282125313280008020
OFFSET
0,2
FORMULA
a(n) = Sum_{k=0..n} [gcd(k, n) = 1] * n^k, where [] is the Iverson bracket.
MAPLE
KS := (n, k) -> NumberTheory:-KroneckerSymbol(n, k):
A367546 := n -> local k; add(n^k * abs(KS(n - k , k)), k = 0..n):
seq(A367546(n), n = 0..20);
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
KEYWORD
nonn
AUTHOR
Peter Luschny, Nov 22 2023
STATUS
approved