Mobius Function Calculator
Find the Mobius value of an integer from its prime factors, with a square-free check and a short reason.
What it does
The Mobius function assigns one of three values to each positive integer: minus one, zero or plus one. Which value appears depends only on the shape of the prime factorization. Any squared prime factor forces zero. If no square divides the number, the value is plus one when there is an even number of distinct primes and minus one when there is an odd number.
The function is named after August Ferdinand Mobius, who introduced it in 1832. Its main use is Mobius inversion, a technique that recovers one arithmetic function from another. If a function f at n equals the sum of g over all divisors of n, then g at n can be recovered by summing mu of each divisor times f of the quotient.
Because the value depends on the prime signature rather than the primes themselves, numbers with the same pattern share a value. For example 6 and 10 are both products of two distinct primes, so both give plus one, while 12 and 18 both contain a squared prime and give zero.
This page factors n, tests for repeated primes, counts the distinct primes and reports the resulting value. It also states whether the input is square free, which is often the part people actually want to know when they meet this function for the first time.
Only whole numbers are accepted, and entries stop at one trillion so the factorization finishes quickly in the browser. The output is a small integer with no unit attached.
How to use
- Enter a whole number n of at least 1.
- Read mu(n) from the main result box.
- Check the square-free flag to see whether any prime repeats.
- Use the distinct prime count to verify the sign.
- Try 30 first, since that is the worked example loaded by default.
- Try 12 to see how a squared factor forces the value to zero.
Formula
- n
- The positive integer being classified.
- p^2
- The square of any prime, which forces zero if it divides n.
- k
- The number of distinct prime factors of a square-free n.
The special case n = 1 has no prime factors and gives mu(1) = 1. For 30 the primes are 2, 3 and 5, so k = 3 and mu(30) = -1. For 12 the factor 2^2 divides the number, so mu(12) = 0 regardless of the other prime. The test depends on exponents only, never on the sizes of the primes.
Worked example
Example: mu(30)
Use n = 30, the default value in the tool.
- Factor 30 as 2 x 3 x 5.
- Check for repeated primes. Each exponent is 1, so the number is square free.
- Count the distinct primes: 2, 3 and 5 gives k = 3.
- An odd k means (-1)^3, which is minus one.
- The tool reports mu(30) = -1, three distinct primes, and square free Yes.
- Compare with 12, where 2^2 forces a value of zero.
Reference table
| n | Factorization | Square free | mu(n) |
|---|---|---|---|
| 1 | none | Yes | 1 |
| 4 | 2^2 | No | 0 |
| 6 | 2 x 3 | Yes | 1 |
| 10 | 2 x 5 | Yes | 1 |
| 12 | 2^2 x 3 | No | 0 |
| 30 | 2 x 3 x 5 | Yes | -1 |
Limits
- The function is defined only for positive integers.
- Inputs above one trillion are rejected to keep factoring fast.
- The tool does not perform a Mobius inversion sum over divisors.
- The sign depends on the count of distinct primes, not on their values.
Common mistakes
- Using the total number of prime factors with repeats instead of the distinct count.
- Forgetting that any squared prime forces zero even when other primes are distinct.
- Assigning minus one to 1 instead of plus one.
- Assuming all even numbers give the same value.
- Confusing this function with the Mobius transform of a sequence.
Try it yourself
Quick checks. Answers sit tucked under each question.
What is mu(12)?
12 = 2^2 x 3, so a squared prime divides it and mu(12) = 0.
What is mu(6)?
6 = 2 x 3 has two distinct primes and no square, so mu(6) = (-1)^2 = 1.
What is mu(1)?
There are no prime factors, so mu(1) = 1 by definition.
Questions
What does square free mean?
No prime squared divides the number, so every exponent in the factorization is one.
Why does a square give zero?
The Mobius function is built to cancel contributions inside inversion sums, and squared factors are assigned zero for that reason.
Do 24 and 375 have the same value?
Yes. Both have prime signature with one exponent of three and one of one, so both contain a square and give zero.
Is mu multiplicative?
Yes. For coprime a and b, mu(ab) equals mu(a) times mu(b).
What is the Mertens function?
It is the running sum of mu values from 1 up to n, often used when studying the distribution of primes.
What input range does this page allow?
Whole numbers from 1 through 1,000,000,000,000. Larger entries show an error message.