On this page
Some functions in number theory are easy to add up over divisors but hard to write down directly. The Möbius function is the tool that runs that addition backwards. August Möbius introduced it in 1832, according to Wolfram MathWorld's entry on the Möbius function, and it now sits under results from Euler's totient to the density of square-free numbers.
What is the Möbius function μ(n)?
The definition, as given in the OEIS entry A008683: μ(1) = 1; μ(n) = (−1)^k if n is the product of k different primes; otherwise μ(n) = 0.
So you only need the prime factorisation:
μ(1) = 1.
μ(7) = −1, because 7 is one prime.
μ(15) = μ(3 × 5) = +1, two different primes.
μ(30) = μ(2 × 3 × 5) = −1, three different primes.
μ(12) = 0, because 12 = 2² × 3 has a repeated prime.
Numbers with no repeated prime, like 15 and 30, are called square-free. For them μ is ±1; for every other number it is 0.
Why does the sum of μ(d) over the divisors of n equal 0?
The key identity, listed on the MathWorld Möbius function page: the sum of μ(d) over all divisors d of n is 1 when n = 1 and 0 for every n > 1.
Here is why. Say n has k different primes. Divisors with a squared prime contribute 0, so only the square-free divisors count, and each of those is a choice of some of the k primes. Choosing j primes gives sign (−1)^j, and there are C(k, j) ways to do it. The total is the binomial expansion of (1 − 1)^k, which is 0 whenever k ≥ 1.
Take n = 30. Its divisors are 1 (+1); 2, 3, 5 (−1 each); 6, 10, 15 (+1 each); and 30 (−1). That is 1 − 3 + 3 − 1 = 0, the same alternating pattern you meet in inclusion-exclusion on a Venn diagram.
What is Möbius inversion?
The MathWorld statement of the Möbius inversion formula reads: if g(n) is the sum of f(d) over the divisors d of n, then f(n) is the sum of μ(d)·g(n/d) over the same divisors.
In words: from the divisor sums g you get the original f back, with μ supplying the signs and the zero-sum identity cancelling the extra terms.
How does Möbius inversion give Euler's φ(n)?
Euler's totient φ(n) counts the numbers from 1 to n that share no factor with n (OEIS A000010). It satisfies a neat divisor identity: the sum of φ(d) over the divisors of n equals n (MathWorld, totient function).
Check it for n = 12. The divisors are 1, 2, 3, 4, 6, 12, with φ values 1, 1, 2, 2, 2, 4. They add to 12.
Now invert, with g(n) = n and f = φ. The formula gives φ(n) as the sum of μ(d)·n/d, the same formula OEIS A000010 lists. For n = 12:
d = 1: μ = +1, term +12.
d = 2: μ = −1, term −6.
d = 3: μ = −1, term −4.
d = 4: μ = 0, term 0.
d = 6: μ = +1, term +2.
d = 12: μ = 0, term 0.
The total is 12 − 6 − 4 + 2 = 4, and indeed only 1, 5, 7 and 11 are coprime to 12. This φ is the same one that powers RSA encryption with tiny primes.
How many square-free numbers are there up to N?
The OEIS entry A013928 gives a counting formula built from μ (stated there for the numbers below n). Written for the numbers up to N, it says the number of square-free numbers up to N is the sum of μ(d)·⌊N/d²⌋ over d from 1 to √N.
The logic is inclusion-exclusion again. Start with all N numbers, remove multiples of 4 and of 9 and of 25, add back multiples of 36 (counted twice), and so on; μ(d) decides each sign. Worked out for N = 100:
d = 1: +100
d = 2: −25 (multiples of 4)
d = 3: −11 (multiples of 9)
d = 5: −4 (multiples of 25)
d = 6: +2 (multiples of 36)
d = 7: −2 (multiples of 49)
d = 10: +1 (multiples of 100)
The values d = 4, 8 and 9 drop out because μ is 0 there. The total is 61, which matches the count of 61 square-free numbers up to 100 in OEIS A071172.
The same entry gives 607,926 square-free numbers up to one million. That is close to 6/π² ≈ 0.6079 of all numbers, the density OEIS A013928 records, and π²/6 is the answer to the Basel problem on the sum of 1/n².
How should you practise this?
Factorise first, every time; μ is read off the factorisation.
Write the divisors in pairs (d, n/d) so you never lose one.
Cross out divisors with a squared prime before adding anything.
If the ideas around it, such as divisors, coprime numbers or inclusion-exclusion, feel shaky, the Fermi Concept Library covers every concept in mathematics, each with its own lesson. When an inversion goes wrong and you cannot see where, the Fermi Problem Library has a step-by-step solver that explains the reasoning rather than printing an answer.



