A007421 Liouville's function: parity of number of primes dividing n (with multiplicity).
2, 1, 1, 2, 1, 2, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 2, 2, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1
Offset: 1
References
- J. Roberts, Lure of the Integers, Math. Assoc. America, 1992, p. 279.
- N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..1000
- H. Gupta, On a table of values of L(n), Proceedings of the Indian Academy of Sciences. Section A, 12 (1940), 407-409. [Annotated scanned copy]
- R. S. Lehman, On Liouville's function, Math. Comp., 14 (1960), 311-320.
Programs
-
Haskell
a007421 = (2 -) . (`mod` 2) . a001222 -- Reinhard Zumkeller, Nov 10 2011
-
Mathematica
a[1] = 2; a[n_] := ((-1)^Total[FactorInteger[n][[All, 2]]] + 3)/2; (* or, from version 7 on : *) a[n_] := Boole[ EvenQ[ PrimeOmega[n]]] + 1; (* or *) a[n_] := (LiouvilleLambda[n] + 3)/2; a[1] = 2; Table[a[n], {n, 1, 105}] (* Jean-François Alcover, Apr 08 2013, updated Jan 27 2015 *)
Formula
a(n) = ((-1)^bigomega(n)+3)/2, where bigomega(n) is the number of prime divisors of the integer n counted with multiplicity.
a(n) = A065043(n) + 1.
a(n) = 2 - A001222(n) mod 2. - Reinhard Zumkeller, Nov 10 2011
Extensions
More terms from Vladeta Jovovic, Dec 01 2001