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.

A050457 a(n) = Sum_{ d divides n, d==1 mod 4} d - Sum_{ d divides n, d==3 mod 4} d.

Original entry on oeis.org

1, 1, -2, 1, 6, -2, -6, 1, 7, 6, -10, -2, 14, -6, -12, 1, 18, 7, -18, 6, 12, -10, -22, -2, 31, 14, -20, -6, 30, -12, -30, 1, 20, 18, -36, 7, 38, -18, -28, 6, 42, 12, -42, -10, 42, -22, -46, -2, 43, 31, -36, 14, 54, -20, -60, -6, 36, 30, -58, -12, 62, -30, -42, 1, 84, 20, -66, 18, 44, -36, -70
Offset: 1

Views

Author

N. J. A. Sloane, Dec 23 1999

Keywords

Comments

Multiplicative because it is the Inverse Moebius transform of [1 0 -3 0 5 0 -7 ...], which is multiplicative. - Christian G. Bower, May 18 2005

Crossrefs

Column k=1 of A322143.

Programs

  • Maple
    with(numtheory):
    A050457 := proc(n)
        local count1, count3, d;
        count1 := 0:
        count3 := 0:
        for d in numtheory[divisors](n) do
            if d mod 4 = 1 then
                count1 := count1+d
            elif d mod 4 = 3 then
                count3 := count3+d
            fi:
        end do:
        count1-count3;
    end proc: # Ridouane Oudra, Feb 02 2020
    # second Maple program:
    a:= n-> add(`if`(d::odd, d*(-1)^((d-1)/2), 0), d=numtheory[divisors](n)):
    seq(a(n), n=1..100);  # Alois P. Heinz, Feb 03 2020
  • Mathematica
    Table[Sum[KroneckerSymbol[-4, d] d , {d, Divisors[n]}], {n,  71}] (* Indranil Ghosh, Mar 16 2017 *)
    f[p_, e_] := If[Mod[p, 4] == 1, (p^(e+1)-1)/(p-1), ((-p)^(e+1)-1)/(-p-1)]; f[2, e_] := 1; a[1] = 1; a[n_] := Times @@ f @@@ FactorInteger[n]; Array[a, 100] (* Amiram Eldar, Sep 27 2023 *)
  • PARI
    {a(n)=local(A,p,e); if(n<1, 0, A=factor(n); prod(k=1,matsize(A)[1], if(p=A[k,1], e=A[k,2]; if(p==2, 1, p*=kronecker(-4,p); (p^(e+1)-1)/(p-1)))))} /* Michael Somos, May 29 2005 */
    
  • PARI
    {a(n)=if(n<1, 0, sumdiv(n, d, kronecker(-4, d)*d))} /* Michael Somos, May 29 2005 */

Formula

a(n) is multiplicative with a(p^e)=1 if p=2, a(p^e)=(p^(e+1)-1)/(p-1) if p == 1 (mod 4), a(p^e)=((-p)^(e+1)-1)/(-p-1) if p == 3 (mod 4). - Michael Somos, May 29 2005
G.f.: Sum_{k>=1} (-1)^(k-1)*(2*k - 1)*x^(2*k-1)/(1 - x^(2*k-1)). - Ilya Gutkovskiy, Dec 22 2018
a(n) = Im(Sum_{d|n} d*i^d). - Ridouane Oudra, Feb 02 2020
a(n) = Sum_{d|n} d*sin(d*Pi/2). - Ridouane Oudra, Feb 18 2023