A162511 Multiplicative function with a(p^e) = (-1)^(e-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, -1
Offset: 1
Links
- G. C. Greubel, Table of n, a(n) for n = 1..5000
- Gérard P. Michon, Multiplicative functions.
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)
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