OFFSET
1,2
FORMULA
a(n) = [x^n] (1/(1 + x)) * Sum_{k>=1} k^n * x^k/(1 - (-x)^k).
a(n) = Sum_{k=1..n} Sum_{d|k} (-1)^(n-d) * d^n.
a(n) ~ c * n^n, where c = 1/(1 + exp(-1)) = 0.7310585786300048792511592418218362743651446401650565192763659... - Vaclav Kotesovec, Aug 22 2019, updated Jul 19 2021
Let A(n,k) = Sum_{j=1..n} j^k * floor(n/j). Then a(n) = (-1)^n*(2^(n+1)*A(floor(n/2),n)-A(n,n)). - Chai Wah Wu, Oct 28 2023
MATHEMATICA
Table[Sum[(-1)^(n - k) k^n Floor[n/k] , {k, 1, n}], {n, 1, 20}]
Table[SeriesCoefficient[1/(1 + x) Sum[k^n x^k/(1 - (-x)^k), {k, 1, n}], {x, 0, n}], {n, 1, 20}]
Table[(-1)^n Sum[DivisorSigma[n, k] - 2 Total[Select[Divisors[k], OddQ]^n], {k, 1, n}], {n, 1, 20}]
PROG
(PARI) a(n)={sum(k=1, n, (-1)^(n-k) * k^n * (n\k))} \\ Andrew Howroyd, Aug 22 2019
(Python)
from math import isqrt
from sympy import bernoulli
def A308313(n): return (-1 if n&1 else 1)*((((s:=isqrt(m:=n>>1))+1)*(bernoulli(n+1)-bernoulli(n+1, s+1))<<n+1)-((t:=isqrt(n))+1)*(bernoulli(n+1)-bernoulli(n+1, t+1))+(sum(w**n*(n+1)*((q:=m//w)+1)-bernoulli(n+1)+bernoulli(n+1, q+1) for w in range(1, s+1))<<n+1)-sum(w**n*(n+1)*((q:=n//w)+1)-bernoulli(n+1)+bernoulli(n+1, q+1) for w in range(1, t+1)))//(n+1)
CROSSREFS
KEYWORD
nonn
AUTHOR
Ilya Gutkovskiy, Aug 22 2019
STATUS
approved