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).

This page as a plain text file.
%I A162511 #43 Oct 26 2023 08:31:19
%S A162511 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,
%T A162511 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,
%U A162511 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
%N A162511 Multiplicative function with a(p^e) = (-1)^(e-1).
%H A162511 G. C. Greubel, <a href="/A162511/b162511.txt">Table of n, a(n) for n = 1..5000</a>
%H A162511 Gérard P. Michon, <a href="http://www.numericana.com/answer/numbers.htm#multiplicative">Multiplicative functions</a>.
%F A162511 Multiplicative function with a(p^e)=(-1)^(e-1) for any prime p and any positive exponent e.
%F A162511 a(n) = 1 when n is a squarefree number (A005117).
%F A162511 From _Reinhard Zumkeller_, Jul 08 2009 (Start)
%F A162511 a(n) = (-1)^(A001222(n)-A001221(n)).
%F A162511 a(A162644(n)) = +1; a(A162645(n)) = -1. (End)
%F A162511 a(n) = A076479(n) * A008836(n). - _R. J. Mathar_, Mar 30 2011
%F A162511 Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = A307868. - _Amiram Eldar_, Sep 18 2022
%F A162511 Dirichlet g.f.: Product_{p prime} ((p^s + 2)/(p^s + 1)). - _Amiram Eldar_, Oct 26 2023
%p A162511 A162511 := proc(n)
%p A162511     local a,f;
%p A162511     a := 1;
%p A162511     for f in ifactors(n)[2] do
%p A162511         a := a*(-1)^(op(2,f)-1) ;
%p A162511     end do:
%p A162511     return a;
%p A162511 end proc: # _R. J. Mathar_, May 20 2017
%t A162511 a[n_] := (-1)^(PrimeOmega[n] - PrimeNu[n]); Array[a, 100] (* _Jean-François Alcover_, Apr 24 2017, after _Reinhard Zumkeller_ *)
%o A162511 (PARI) a(n)=my(f=factor(n)[,2]); prod(i=1,#f,-(-1)^f[i]) \\ _Charles R Greathouse IV_, Mar 09 2015
%o A162511 (Python)
%o A162511 from sympy import factorint
%o A162511 from operator import mul
%o A162511 def a(n):
%o A162511     f=factorint(n)
%o A162511     return 1 if n==1 else reduce(mul, [(-1)**(f[i] - 1) for i in f]) # _Indranil Ghosh_, May 20 2017
%o A162511 (Python)
%o A162511 from functools import reduce
%o A162511 from sympy import factorint
%o A162511 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
%Y A162511 Cf. A005117, A076479, A162510, A162512, A002035, A072587, A036537, A162643, A162644, A162645, A046660, A008836, A307868.
%K A162511 easy,mult,sign
%O A162511 1,1
%A A162511 _Gerard P. Michon_, Jul 05 2009