Maths & numbers

Liouville function calculator

Determine parity of the number of prime factors counted with multiplicity.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Multiplying by a prime flips the sign, even if that prime already appears in the factorization.

THE FORMULAλ(n) = (−1)^Ω(n)

A worked example

12 = 2 × 2 × 3 has three prime factors with multiplicity, giving −1.

Good to know

The empty factorization of 1 gives +1.

Count prime factors with repetition

Write 12 as 2 × 2 × 3. Counting every prime factor gives Ω(12) = 3. The Liouville value is λ(12) = (−1)³ = −1. By contrast, 18 = 2 × 3 × 3 also has three factors and the same value, even though its prime exponents differ.

For 36 = 2² × 3², the exponent sum is 2 + 2 = 4, an even number, so λ(36) = 1. The output depends on parity of the total exponent count. It does not require multiplying the full expanded factor list once the exponents are known.

Twelve has three prime-factor occurrences when repeated factors are counted22312 = 2 × 2 × 3Three occurrences → λ(12) = −136 = 2² × 3² → λ(36) = +1
Both copies of 2 count. The total 1 + 1 + 1 = 3 is odd, giving λ(12) = −1.

Use multiplication to check the sign

The Liouville function is completely multiplicative. Prime exponents add when integers multiply, so λ(ab) = λ(a)λ(b), including when a and b share a prime factor. For example, λ(6) = 1 and λ(2) = −1, giving λ(12) = −1.

The Möbius function calculator additionally tests for prime squares and can return zero. Liouville never returns zero for an accepted positive input. A perfect square has even prime exponents, so its exponent total is even and its Liouville value is 1. The value for 1 is also 1 because its factorization has zero prime factors and (−1)⁰ = 1.

A few questions, answered

Do I count two distinct primes in 12?

It has two distinct primes but three prime factors with multiplicity. Liouville uses the latter count.

Can different integers share the same output?

Yes. Only the parity of the exponent total is retained, so many integers map to each of the two possible values.

Find your calculator

Start typing to explore the library.