OFFSET
1,6
FORMULA
Let A(n, k) = Sum_{j=1..n} j^k * floor(n/j). Then T(n, k) = 2^(k+1)*A(floor(n/2), k) - A(n, k).
EXAMPLE
Array begins:
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ...
-1, 0, 2, 6, 14, 30, 62, 126, 254, 510, ...
-3, -4, -8, -22, -68, -214, -668, -2062, -6308, -19174, ...
-2, 1, 11, 49, 203, 841, 3491, 14449, 59483, 243481, ...
-4, -5, -15, -77, -423, -2285, -12135, -63677, -331143, -1709645, ...
PROG
(Python)
from math import isqrt
from itertools import count, islice
from sympy import bernoulli
def A366936_T(n, k):
if k:
return ((((s:=isqrt(m:=n>>1))+1)*(bernoulli(k+1)-bernoulli(k+1, s+1))<<k+1)-((t:=isqrt(n))+1)*(bernoulli(k+1)-bernoulli(k+1, t+1))+(sum(w**k*(k+1)*((q:=m//w)+1)-bernoulli(k+1)+bernoulli(k+1, q+1) for w in range(1, s+1))<<k+1)-sum(w**k*(k+1)*((q:=n//w)+1)-bernoulli(k+1)+bernoulli(k+1, q+1) for w in range(1, t+1)))//(k+1) if n else -1
else:
return (s:=isqrt(n))**2-((t:=isqrt(m:=n>>1))**2<<1)+((sum(m//k for k in range(1, t+1))<<1)-sum(n//k for k in range(1, s+1))<<1)
CROSSREFS
KEYWORD
sign,tabl
AUTHOR
Chai Wah Wu, Oct 29 2023
STATUS
approved