gives the Liouville function .

Details and Options

  • LiouvilleLambda is also known as Liouville function.
  • Integer mathematical function, suitable for both symbolic and numerical manipulation.
  • LiouvilleLambda[n] gives 1 whenever the number of prime factors counting multiplicity of n is even and -1 otherwise.
  • For a number n=u p1k1 pmkm with u a unit and pi primes, LiouvilleLambda[n] returns (-1)k1++km.
  • With the setting GaussianIntegers->True, LiouvilleLambda is defined using factorization over Gaussian integers.
  • LiouvilleLambda[m+In] automatically works over Gaussian integers.


open allclose all

Basic Examples  (2)

Compute the Liouville function at and :

Plot the LiouvilleLambda sequence for the first 20 numbers:

Scope  (8)

Numerical Evaluation  (4)

LiouvilleLambda works over integers:

Gaussian integers:

Compute for large integers:

LiouvilleLambda threads over lists:

Symbolic Manipulation  (4)

TraditionalForm formatting:

Reduce expressions:

Solve equations:

DirichletTransform of LiouvilleLambda:


Options  (1)

GaussianIntegers  (1)

Compute LiouvilleLambda over integers:

Gaussian integers:

Applications  (5)

Basic Applications  (2)

Highlight numbers for which Liouville's function is in blue and for which it is in red:

Histogram of the cumulative values of LiouvilleLambda:

Number Theory  (3)

LiouvilleLambda and MoebiusMu are related by the equation :

Use LiouvilleLambda to compute MoebiusMu:

Plot the summatory function :

Properties & Relations  (5)

LiouvilleLambda is a completely multiplicative function:

LiouvilleLambda gives when the argument is a product of an even number of primes:

Otherwise, it gives :

Use FactorInteger to compute LiouvilleLambda:

Use PrimeOmega to compute LiouvilleLambda:

gives for a perfect square n and otherwise:

Neat Examples  (3)

Plot LiouvilleLambda for the sum of two squares:

Plot the arguments of the Fourier transform of LiouvilleLambda:

Plot the Ulam spiral of LiouvilleLambda:

Wolfram Research (2008), LiouvilleLambda, Wolfram Language function,


Wolfram Research (2008), LiouvilleLambda, Wolfram Language function,


Wolfram Language. 2008. "LiouvilleLambda." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2008). LiouvilleLambda. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2023_liouvillelambda, author="Wolfram Research", title="{LiouvilleLambda}", year="2008", howpublished="\url{}", note=[Accessed: 22-April-2024 ]}


@online{reference.wolfram_2023_liouvillelambda, organization={Wolfram Research}, title={LiouvilleLambda}, year={2008}, url={}, note=[Accessed: 22-April-2024 ]}