Maths & numbers

Möbius function calculator

Evaluate the Möbius function from prime multiplicities.

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

The value for 12 is zero because 4 divides it. A single repeated prime factor is enough to make the value zero.

THE FORMULAμ(n) = 0 if a prime square divides n, otherwise (−1)ᵏ

A worked example

30 = 2 × 3 × 5 has three distinct primes, so μ(30) = −1.

Good to know

By convention μ(1) = 1.

Check for repeated primes before counting signs

The default input 30 factors as 2 × 3 × 5. Each prime appears once, so the factorization is squarefree. There are three distinct primes, giving μ(30) = (−1)³ = −1. For 6 = 2 × 3, the count is even and μ(6) = 1.

A repeated prime changes the rule. For 12 = 2² × 3, the square 2² divides the input, so μ(12) = 0. Once a prime square is present, there is no need to use the parity of the remaining primes. This squarefree test is the first branch of the implementation.

Thirty has three different prime factors and Möbius value negative one23530 = 2 × 3 × 5Three distinct primes → μ(30) = −112 = 2² × 3 → μ(12) = 0
Three distinct factors produce the sign (−1)³ = −1. A repeated factor would instead make the Möbius value zero.

Compare Möbius and Liouville values

The Liouville function calculator counts all prime factors with multiplicity and always returns 1 or −1. On a squarefree input, that total equals the count of distinct primes, so the two functions agree. On 12, Liouville counts three factors and returns −1 while Möbius returns zero.

A useful identity is the sum of μ(d) over all positive divisors d of n. It equals zero for n above one. For n = 6 the four terms are μ(1) + μ(2) + μ(3) + μ(6) = 1 − 1 − 1 + 1 = 0. The input 1 is the exceptional starting value, with μ(1) = 1.

A few questions, answered

Does a squarefree input have to be prime?

No. Thirty is squarefree and composite because none of its prime factors repeats.

What happens for a prime square?

Any prime square has Möbius value zero because it contains a repeated prime factor.

Find your calculator

Start typing to explore the library.