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.

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

Original entry on oeis.org

-1, 0, -4, 1, -5, -1, -9, 4, -9, -3, -15, 5, -9, -1, -25, 4, -14, -1, -21, 9, -23, -11, -35, 17, -14, 0, -40, 0, -30, -6, -38, 23, -25, -7, -55, 10, -28, -8, -64, 14, -28, 4, -40, 20, -58, -34, -82, 34, -23, 8, -64, 6, -48, -8, -80, 24, -56, -26, -86, 34, -28, 4, -100, 25, -59
Offset: 1

Views

Author

Keywords

Comments

n - 2*[ n/2 ] + 3*[ n/3 ] - ... + m*n*[ n/n ], where m = (-1)^(n+1).

Crossrefs

The zeros are A072663.
Partial sums of A002129.

Programs

  • Magma
    [&+[(-1)^k*k*(n div k): k in [1..n]]: n in [1..70]]; // Vincenzo Librandi, Jul 28 2019
    
  • Mathematica
    f[n_] := Sum[(-1)^i*i*Floor[n/i], {i, 1, n}]; Table[ f[n], {n, 1, 85}]
  • PARI
    a(n) = sum(k=1, n, (-1)^k*k*floor(n/k));
    
  • Python
    from math import isqrt
    def A024919(n): return (-(s:=isqrt(m:=n>>1))**2*(s+1) + sum((q:=m//k)*((k<<1)+q+1) for k in range(1,s+1))<<1)+((s:=isqrt(n))**2*(s+1)-sum((q:=n//k)*((k<<1)+q+1) for k in range(1,s+1))>>1) # Chai Wah Wu, Oct 22 2023

Formula

a(n) = 4*A024916(floor(n/2)) - A024916(n). - Vladeta Jovovic, Oct 15 2002
G.f.: 1/(1-x) * Sum_{n>=1} n*x^n*(3*x^n-1)/(1-x^(2*n)). - Vladeta Jovovic, Oct 15 2002
G.f.: -1/(1-x) * Sum_{k>=1} x^k/(1+x^k)^2 = 1/(1-x) * Sum_{k>=1} k * (-x)^k/(1-x^k). - Seiichi Manyama, Oct 29 2023

Extensions

Edited by Robert G. Wilson v, Aug 17 2002