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.
μ(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.
Reference: NIST DLMF, Functions of Number Theory (opens in a new tab) ↗
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.
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.
Read more: NIST DLMF number-theoretic functions (opens in a new tab) ↗
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.