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.

A162511 Multiplicative function with a(p^e) = (-1)^(e-1).

Original entry on oeis.org

1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1
Offset: 1

Views

Author

Gerard P. Michon, Jul 05 2009

Keywords

Crossrefs

Programs

  • Maple
    A162511 := proc(n)
        local a,f;
        a := 1;
        for f in ifactors(n)[2] do
            a := a*(-1)^(op(2,f)-1) ;
        end do:
        return a;
    end proc: # R. J. Mathar, May 20 2017
  • Mathematica
    a[n_] := (-1)^(PrimeOmega[n] - PrimeNu[n]); Array[a, 100] (* Jean-François Alcover, Apr 24 2017, after Reinhard Zumkeller *)
  • PARI
    a(n)=my(f=factor(n)[,2]); prod(i=1,#f,-(-1)^f[i]) \\ Charles R Greathouse IV, Mar 09 2015
    
  • Python
    from sympy import factorint
    from operator import mul
    def a(n):
        f=factorint(n)
        return 1 if n==1 else reduce(mul, [(-1)**(f[i] - 1) for i in f]) # Indranil Ghosh, May 20 2017
    
  • Python
    from functools import reduce
    from sympy import factorint
    def A162511(n): return -1 if reduce(lambda a,b:~(a^b), factorint(n).values(),0)&1 else 1 # Chai Wah Wu, Jan 01 2023

Formula

Multiplicative function with a(p^e)=(-1)^(e-1) for any prime p and any positive exponent e.
a(n) = 1 when n is a squarefree number (A005117).
From Reinhard Zumkeller, Jul 08 2009 (Start)
a(n) = (-1)^(A001222(n)-A001221(n)).
a(A162644(n)) = +1; a(A162645(n)) = -1. (End)
a(n) = A076479(n) * A008836(n). - R. J. Mathar, Mar 30 2011
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = A307868. - Amiram Eldar, Sep 18 2022
Dirichlet g.f.: Product_{p prime} ((p^s + 2)/(p^s + 1)). - Amiram Eldar, Oct 26 2023