Mobius Function Calculator

Use this Mobius Function Calculator to enter values, adjust options, and review results in a compact responsive workspace.

Results are calculated automatically as you enter data.

Factor n, test square-freeness, and explore nearby mu values.

Formula and divisor-sum check
Result Enter a positive integer.

▼ See explanations and tips below ▼

What Is the Möbius Function?

The Möbius function is a number-theory function that assigns every positive integer one of three values: \(1\), \(0\), or \(-1\). Its value depends entirely on the prime factorization of the integer.

The basic question is: does the number contain a repeated prime factor? If it does, the Möbius value is \(0\). If it does not, the number is square-free, and the sign is determined by how many distinct prime factors it has.

For example, \(30 = 2 \times 3 \times 5\) has three distinct prime factors and no repeated prime factor, so \(\mu(30) = -1\). By contrast, \(72 = 2^3 \times 3^2\) contains repeated prime factors, so \(\mu(72) = 0\).

The Möbius function is useful because it turns prime-factor information into a compact signal. It helps identify square-free numbers, supports divisor-sum identities, and plays a central role in Möbius inversion, which is a method for undoing certain sums over divisors.


Why the Möbius Function Matters

The Möbius function is small in output but powerful in meaning. It is used in elementary number theory, analytic number theory, combinatorics, and arithmetic-function calculations.

It matters because it helps answer questions such as:

  • Is this integer square-free?
  • Does a divisor sum cancel to zero?
  • How can a formula that sums over divisors be inverted?
  • How do positive and negative contributions from square-free numbers accumulate?

The function is especially useful for students learning how prime factorization controls number-theory functions. Instead of treating a number as a single object, the Möbius function asks what primes build it and whether any of those primes repeat.


Key Terms to Know

  • Prime factorization: Writing a positive integer as a product of powers of primes, such as \(72 = 2^3 \times 3^2\).
  • Prime exponent: The power on a prime in the factorization. In \(2^3\), the exponent is \(3\).
  • Square-free integer: A positive integer not divisible by \(p^2\) for any prime \(p\). For example, \(30\) is square-free, but \(12\) is not because \(2^2 \mid 12\).
  • Distinct prime factors: The different primes that divide a number, counted once each. For \(72 = 2^3 \times 3^2\), the distinct prime factors are \(2\) and \(3\).
  • Divisor: A positive integer \(d\) that divides \(n\) with no remainder.
  • Arithmetic function: A function whose input is a positive integer and whose output is usually a number connected to the integer’s arithmetic structure.
  • Mertens function: The cumulative sum of Möbius values from \(1\) through \(n\).

How the Möbius Function Works

The Möbius function is defined for positive integers. Its rule is:

$$ \mu(n)= \begin{cases} 1, & n=1,\\ 0, & p^2 \mid n \text{ for some prime } p,\\ (-1)^k, & n \text{ is a product of } k \text{ distinct primes.} \end{cases} $$

In plain language:

  1. If \(n = 1\), then \(\mu(n) = 1\).
  2. If any prime appears more than once in the factorization of \(n\), then \(\mu(n) = 0\).
  3. If no prime repeats, count the distinct prime factors:
  • even count gives \(\mu(n)=1\);
  • odd count gives \(\mu(n)=-1\).

The exponent check is the fastest way to understand the function. If the factorization contains any exponent greater than \(1\), the result is immediately \(0\).

For a square-free number with \(k\) distinct prime factors, the sign alternates:

$$ \mu(n)=(-1)^k $$

So one prime factor gives \(-1\), two distinct prime factors give \(1\), three distinct prime factors give \(-1\), and so on.


Examples of the Möbius Function in Practice

Example 1: The special case \(n=1\)

The number \(1\) has no prime factors. The Möbius function is defined so that:

$$ \mu(1)=1 $$

This special definition is important because it makes divisor-sum identities work cleanly. When \(n=1\), the only positive divisor is \(1\), so the divisor sum is also \(1\).


Example 2: A prime number

Let \(n=97\). Since \(97\) is prime, its factorization is just:

$$ 97 = 97 $$

There is one distinct prime factor, so \(k=1\). Therefore:

$$ \mu(97)=(-1)^1=-1 $$

Every prime number has Möbius value \(-1\).


Example 3: A square-free composite number

Let \(n=30\). Its prime factorization is:

$$ 30 = 2 \times 3 \times 5 $$

No prime is repeated, so \(30\) is square-free. It has three distinct prime factors, so:

$$ \mu(30)=(-1)^3=-1 $$

A square-free number with an odd number of distinct prime factors has Möbius value \(-1\).


Example 4: A square-free number with an even number of prime factors

Let \(n=6\). Its factorization is:

$$ 6 = 2 \times 3 $$

There are two distinct prime factors and no repeated prime factor. Since \(2\) is even:

$$ \mu(6)=(-1)^2=1 $$

A Möbius value of \(1\) does not mean the number is prime. It means the number is square-free and has an even number of distinct prime factors.


Example 5: A number with repeated prime factors

Let \(n=72\). Its prime factorization is:

$$ 72 = 2^3 \times 3^2 $$

Both \(2\) and \(3\) appear with exponents greater than \(1\). Since a squared prime factor divides \(72\), the Möbius value is:

$$ \mu(72)=0 $$

The sign rule is not used once a repeated prime factor appears. Repetition makes the result zero.


The Divisor-Sum Identity

One of the most important facts about the Möbius function is its divisor-sum identity:

$$ \sum_{d \mid n} \mu(d)= \begin{cases} 1, & n=1,\\ 0, & n>1. \end{cases} $$

The notation \(\sum_{d \mid n}\) means “sum over all positive divisors \(d\) of \(n\).”

For \(n=30\), the divisors are \(1,2,3,5,6,10,15,30\). Their Möbius values are:

Divisor \(d\) \(\mu(d)\)
\(1\) \(1\)
\(2\) \(-1\)
\(3\) \(-1\)
\(5\) \(-1\)
\(6\) \(1\)
\(10\) \(1\)
\(15\) \(1\)
\(30\) \(-1\)

Adding these values gives:

$$ 1-1-1-1+1+1+1-1=0 $$

That cancellation is not a coincidence. For every \(n>1\), the sum of \(\mu(d)\) over all divisors of \(n\) is \(0\).


The Mertens Function

The Mertens function is the running total of Möbius values:

$$ M(n)=\sum_{k=1}^{n}\mu(k) $$

This is different from \(\mu(n)\). The value \(\mu(n)\) describes one integer, while \(M(n)\) adds all Möbius values from \(1\) through \(n\).

For example:

$$ M(5)=\mu(1)+\mu(2)+\mu(3)+\mu(4)+\mu(5) $$

Using the values \(1,-1,-1,0,-1\):

$$ M(5)=1-1-1+0-1=-2 $$

The Mertens function is useful for seeing how the positive, negative, and zero values of the Möbius function accumulate over a range of integers. It should not be interpreted as the Möbius value of the current input.


How to Interpret the Result

A Möbius result has a very specific meaning:

  • \(\mu(n)=0\) means \(n\) has at least one repeated prime factor. Equivalently, \(n\) is not square-free.
  • \(\mu(n)=1\) means \(n\) is square-free and has an even number of distinct prime factors. This includes \(n=1\), which has zero prime factors.
  • \(\mu(n)=-1\) means \(n\) is square-free and has an odd number of distinct prime factors.

The factorization explains the result. If any prime power such as \(2^2\), \(3^2\), \(5^2\), or a higher power appears, the result is zero. If all prime exponents are \(1\), the result depends on whether the number of different primes is even or odd.

The divisor-sum check is a consistency test. It should give \(1\) only when \(n=1\); for every larger positive integer, it should give \(0\).

If a nearby-value graph is shown, each bar represents an individual value \(\mu(k)\). Up bars represent \(1\), down bars represent \(-1\), and short bars represent \(0\). The nearby graph is not cumulative; cumulative behavior belongs to the Mertens function.


Common Mistakes and Misconceptions

Counting prime factors with multiplicity

For the sign of \(\mu(n)\), count distinct prime factors only. For example:

$$ 72=2^3 \times 3^2 $$

The distinct prime factors are \(2\) and \(3\), but the repeated exponents mean \(\mu(72)=0\). You do not count \(2,2,2,3,3\) and then apply the sign rule.

Treating zero as an error

A result of \(0\) is a normal Möbius value. It means the number has a squared prime factor. For example, \(\mu(12)=0\) because \(12\) is divisible by \(2^2\).

Forgetting the special case \(n=1\)

The value \(\mu(1)=1\) is part of the definition. It is not found by prime factorization in the usual way, because \(1\) has no prime factors.

Assuming \(\mu(n)=1\) means “prime”

Prime numbers have Möbius value \(-1\), not \(1\), because a prime has one distinct prime factor. A value of \(1\) means an even number of distinct prime factors, including zero in the case of \(1\).

Confusing \(\mu(n)\) with \(M(n)\)

The value \(\mu(n)\) belongs to one integer. The value \(M(n)\) is a cumulative sum:

$$ M(n)=\mu(1)+\mu(2)+\cdots+\mu(n) $$

A nearby sequence or graph of \(\mu(k)\) values is not the same as the Mertens cumulative sum.


When to Use the Möbius Function

Use the Möbius function when you need to:

  • decide whether a number is square-free;
  • classify a positive integer by its distinct prime-factor parity;
  • verify the divisor-sum identity for a number;
  • study arithmetic functions and divisor sums;
  • introduce Möbius inversion;
  • compare individual \(\mu(k)\) values around a chosen integer;
  • examine cumulative behavior using the Mertens function.

It is most useful when the prime factorization of an integer matters more than the size of the integer itself.


Limitations and Things to Keep in Mind

The Möbius function is defined for positive integers. It does not apply to zero, negative integers, decimals, fractions, complex numbers, or symbolic expressions in this calculator context.

The calculator accepts integer \(n\) values from \(1\) to \(1{,}000{,}000{,}000{,}000\). Values outside that range are not supported. Non-integer inputs are rejected rather than rounded.

The sequence radius controls how many nearby values are requested on each side of \(n\). It must be an integer from \(2\) to \(25\). The preview is capped at 41 values for responsiveness, so the largest requests are shortened around \(n\); this never changes the displayed \(\mu(n)\). Near the lower or upper input boundary, the preview is also clipped to stay inside the supported range.

The optional Mertens calculation is limited to \(n \le 200{,}000\) for responsiveness. For larger \(n\), the current Möbius value can still be computed within the supported input range, but the cumulative Mertens value is not calculated.

All main mathematical outputs are exact integers or yes/no statuses. The graph is a visual aid, so display formatting may affect coordinates or labels, but not the underlying Möbius values.

Factorization uses cached prime divisors through \(\sqrt{10^{12}}\), so supported inputs remain practical in the browser. For research, cryptography, or large-scale number-theory computations, use specialized mathematical software and independent verification.


How to Use This Calculator

  1. Enter a positive integer \(n\) from \(1\) to \(1{,}000{,}000{,}000{,}000\).
  2. Enter a sequence radius from \(2\) to \(25\) to request nearby values around \(n\). Large requests may be shortened to the 41-value responsive preview.
  3. Check the Mertens option only when you want \(M(n)\); it is computed only for \(n \le 200{,}000\).
  4. Use the example buttons if you want quick test cases such as a square-free number, a number with a square factor, or a prime number.
  5. Review \(\mu(n)\), the prime factorization, square-free status, distinct prime-factor count, divisor sum, and optional Mertens value.
  6. Use the nearby sequence and graph to compare \(\mu(k)\) values around the chosen number.
  7. Use the divisor-sum check to confirm how the Möbius values of the divisors cancel.
  8. Download the graph as a PNG if you want to save the current visual result.

Frequently Asked Questions

What does \(\mu(n)=0\) mean?

It means \(n\) has at least one repeated prime factor. In other words, some prime square \(p^2\) divides \(n\). This is the correct result for numbers such as \(4\), \(8\), \(9\), \(12\), and \(72\).


What does \(\mu(n)=1\) mean?

It means \(n\) is square-free and has an even number of distinct prime factors. For example, \(6=2 \times 3\), so \(\mu(6)=1\). The special case \(n=1\) also has Möbius value \(1\).


What does \(\mu(n)=-1\) mean?

It means \(n\) is square-free and has an odd number of distinct prime factors. Every prime number has Möbius value \(-1\), and so does a square-free product of three distinct primes such as \(30=2 \times 3 \times 5\).


Why is \(\mu(1)=1\)?

The value \(\mu(1)=1\) is part of the definition. It makes the Möbius function behave correctly in divisor sums and Möbius inversion. Since \(1\) has no prime factors, it is treated as the neutral starting case.


Is the divisor-sum check supposed to equal \(\mu(n)\)?

No. The divisor-sum check adds \(\mu(d)\) over all positive divisors \(d\) of \(n\). It should equal \(1\) when \(n=1\) and \(0\) for every \(n>1\), so it is a separate identity rather than a repeat of the main result.


What is the difference between \(\mu(n)\) and \(M(n)\)?

The value \(\mu(n)\) is the Möbius value of one integer. The value \(M(n)\) is the cumulative sum of all Möbius values from \(1\) through \(n\). That means \(M(n)\) depends on every previous value, not only on the factorization of the current input.


Sources and References

Books

  1. Tom M. Apostol. Introduction to Analytic Number Theory. Springer-Verlag, 1976. Undergraduate Texts in Mathematics. Chapter 2, “Arithmetical Functions and Dirichlet Multiplication,” especially the sections on the Möbius function, Dirichlet products, and Möbius inversion. ISBN 978-0-387-90163-3.
  2. G. H. Hardy and E. M. Wright; revised by D. R. Heath-Brown and Joseph H. Silverman, with a foreword by Andrew Wiles. An Introduction to the Theory of Numbers. 6th ed., Oxford University Press, 2008. Chapter 16, “The Arithmetical Functions ø(n), µ(n), d(n), σ(n), r(n).” ISBN 978-0-19-921986-5.

Online and Educational Sources

  1. Eric W. Weisstein. “Moebius Function.” Wolfram MathWorld, accessed July 4, 2026.
  2. Eric W. Weisstein. “Mertens Function.” Wolfram MathWorld, accessed July 4, 2026.
  3. ProofWiki. “Sum of Möbius Function over Divisors.” Last edited February 9, 2024; accessed July 4, 2026.