cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A366915 a(n) = Sum_{k=1..n} (-1)^k*k^2*floor(n/k).

Original entry on oeis.org

-1, 2, -8, 11, -15, 15, -35, 48, -43, 35, -87, 103, -67, 83, -177, 162, -128, 145, -217, 277, -223, 143, -387, 443, -208, 302, -518, 432, -410, 370, -592, 771, -449, 421, -879, 850, -520, 566, -1134, 1024, -658, 842, -1008, 1310, -1056, 534, -1676, 1714, -737
Offset: 1

Views

Author

Chai Wah Wu, Oct 28 2023

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_]:=Sum[ (-1)^k*k^2*Floor[n/k],{k,n}]; Array[a,49] (* Stefano Spezia, Oct 29 2023 *)
  • PARI
    a(n) = sum(k=1, n, (-1)^k*k^2*(n\k)); \\ Michel Marcus, Oct 29 2023
  • Python
    from math import isqrt
    def A366915(n): return (-(t:=isqrt(m:=n>>1))**2*(t+1)*((t<<1)+1)+sum((q:=m//k)*(6*k**2+q*((q<<1)+3)+1) for k in range(1,t+1))<<2)//3+((s:=isqrt(n))**2*(s+1)*((s<<1)+1)-sum((q:=n//k)*(6*k**2+q*((q<<1)+3)+1) for k in range(1,s+1)))//6
    

Formula

a(n) = 8*A064602(floor(n/2))-A064602(n).