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.

A333505 a(n) = Sum_{k=1..n} (-1)^(k+1) * k * ceiling(n/k).

Original entry on oeis.org

1, 0, 2, 2, 2, 2, 5, 5, 1, 4, 9, 9, 2, 2, 9, 17, 5, 5, 11, 11, 2, 12, 23, 23, -4, 1, 14, 26, 15, 15, 22, 22, -6, 8, 25, 37, 9, 9, 28, 44, 7, 7, 18, 18, 3, 35, 58, 58, -9, -2, 18, 38, 21, 21, 36, 52, 5, 27, 56, 56, -3, -3, 28, 68, 8, 26, 45, 45, 24, 50, 73, 73, -23, -23, 14
Offset: 1

Views

Author

Ilya Gutkovskiy, May 25 2020

Keywords

Crossrefs

Programs

  • Mathematica
    Table[Sum[(-1)^(k + 1) k Ceiling[n/k], {k, 1, n}], {n, 1, 75}]
    Table[(-1)^(n + 1) Ceiling[n/2] + Sum[DivisorSum[k, (-1)^(# + 1) # &], {k, 1, n - 1}], {n, 1, 75}]
    nmax = 75; CoefficientList[Series[x/(1 - x) (1/(1 + x)^2 + Sum[(-1)^(k + 1) k x^k/(1 - x^k), {k, 1, nmax}]), {x, 0, nmax}], x] // Rest
  • PARI
    a(n) = sum(k=1, n, (-1)^(k+1)*k*ceil(n/k)); \\ Michel Marcus, May 26 2020
    
  • Python
    from math import isqrt
    def A333505(n): return ((s:=isqrt(m:=n-1>>1))**2*(s+1)-sum((q:=m//k)*((k<<1)+q+1) for k in range(1,s+1))<<1)-((t:=isqrt(n-1))**2*(t+1)-sum((q:=(n-1)//k)*((k<<1)+q+1) for k in range(1,t+1))>>1) + (m+1 if n&1 else -m-1) # Chai Wah Wu, Oct 30 2023

Formula

G.f.: (x/(1 - x)) * (1/(1 + x)^2 + Sum_{k>=1} (-1)^(k+1) * k * x^k / (1 - x^k)).
a(n) = (-1)^(n+1) * ceiling(n/2) + Sum_{k=1..n-1} A002129(k).
a(n) = A001057(n) - A024919(n-1).