Mertens Function Calculator

Mobius sum

M(1,000) — the Mertens function2
mu(1,000) — the Mobius value at x0
squarefree integers up to x, Q(x)608
M(x) / sqrt(x)0.06
How this was calculated
  1. The Mobius function mu(k) is 0 when k has a squared prime factor, +1 when k is a product of an even number of distinct primes, and -1 for an odd number.
  2. A linear sieve computes mu(k) for every k up to 1,000 in one pass.
  3. The Mertens function is the running sum of those values: M(x) = mu(1) + ... + mu(x) = 2.
  4. Of the 1,000 integers, 608 are squarefree — 305 with mu = +1 and 303 with mu = -1, and their difference is exactly M(x).

The Mertens function calculator computes M(x), the running sum of the Möbius function: M(x) = mu(1) + mu(2) + ... + mu(x). Enter a value of x and the tool adds up mu(k) for every integer k from 1 to x and returns the total, along with the intermediate counts that explain it. For example, M(10) = -1, M(100) = 1 and M(1000) = 2. Each mu(k) is 0 when k has a squared prime factor, +1 when k is a product of an even number of distinct primes, and -1 when the number of distinct primes is odd. Up to 1,000 there are 608 squarefree integers, and their signs split so that the +1 count minus the -1 count equals M(1000) = 2.

This direct summation is the accepted standard for the Mertens function because it follows the definition itself, with no approximation or shortcut. The page shows the formula, step-by-step workings, worked examples and sources, so you can check every term rather than trust a black box. It also puts the results in context: the Mertens conjecture, which claimed |M(x)| < sqrt(x) always, was disproved in 1985, yet M(x) / sqrt(x) stays small in practice, at 0.06 when x = 1000. That makes the calculator useful for seeing how the running sum behaves at the size you choose.

Worked examples

M(10)

(10)

M(10) — the Mertens function-1
mu(10) — the Mobius value at x1
squarefree integers up to x, Q(x)7
M(x) / sqrt(x)-0.32

M(100)

(100)

M(100) — the Mertens function1
mu(100) — the Mobius value at x0
squarefree integers up to x, Q(x)61
M(x) / sqrt(x)0.10

M(1000)

(1000)

M(1,000) — the Mertens function2
mu(1,000) — the Mobius value at x0
squarefree integers up to x, Q(x)608
M(x) / sqrt(x)0.06

What is the Mertens function?

The Mertens function, written M(x), is the running sum of the Mobius function. Add up mu(1), mu(2), and so on through mu(x), and the total you reach is M(x). That is the whole definition: M(x) = mu(1) + mu(2) + ... + mu(x). Because each mu value is small, the sum grows slowly, and its value at any point depends on how the plus and minus contributions have balanced out up to that point.

The individual terms come from the Mobius function, mu(k). When k has a squared prime factor, mu(k) is 0. When k is a product of an even number of distinct primes, mu(k) is +1. When k is a product of an odd number of distinct primes, mu(k) is -1. So the Mertens function is really a tally: it counts the squarefree integers up to x whose Mobius sign is +1, subtracts those with sign -1, and ignores everything divisible by a square.

A few anchor values make the behavior concrete. M(10) = -1, M(100) = 1, and M(1000) = 2. That last value can be checked directly from the pieces: up to 1,000 there are 608 squarefree integers, and their Mobius signs split so that the +1 count minus the -1 count equals M(1000) = 2. In other words, after a thousand terms of plus and minus ones, the running total has drifted only two steps from zero.

This slow drift is what makes the Mertens function interesting. The Mertens conjecture held that |M(x)| < sqrt(x) for every x. It was disproved in 1985, so the bound fails somewhere, even if no one encounters trouble in ordinary ranges. In practice M(x) / sqrt(x) stays small: at x = 1000 the ratio is 0.06. That gap between a false general claim and tame observed values is a large part of why the function still draws attention.

  • M(x) is the running sum of the Mobius function from mu(1) through mu(x).
  • mu(k) is 0 if k has a squared prime factor, +1 for an even number of distinct primes, and -1 for an odd number.
  • Anchor values: M(10) = -1, M(100) = 1, M(1000) = 2.
  • Up to 1,000 there are 608 squarefree integers; their signs give M(1000) = 2.
  • The Mertens conjecture, |M(x)| < sqrt(x), was disproved in 1985, yet M(x) / sqrt(x) is 0.06 at x = 1000.
The Mertens function is a running sum, so its value at x is just the net balance of +1 and -1 Mobius terms up to that point. At x = 1000 the balance is only 2.

How M(x) is computed

Computing the Mertens function at a value x means evaluating mu(k) for every integer k from 1 to x and adding the results in order. The Mobius function mu(k) takes only three values: it is 0 when k has a squared prime factor, +1 when k is a product of an even number of distinct primes, and -1 when k is a product of an odd number of distinct primes. The Mertens function M(x) is then the running sum of the Mobius function: M(x) = mu(1) + mu(2) + ... + mu(x). A calculator that follows this definition directly will agree with the known values M(10) = -1, M(100) = 1 and M(1000) = 2.

The usual way to get every mu(k) up to x in one pass is a linear sieve. The sieve walks k upward and keeps track of the smallest prime factor of each number, so every composite is generated exactly once rather than being marked repeatedly. From that information each mu(k) follows: a number that has a squared prime factor receives 0, and a squarefree number receives +1 or -1 according to the parity of its number of distinct prime factors. Because each integer is touched a constant number of times, the whole table of mu values up to x is built in linear time, and the running sum can be accumulated as the table is filled.

The squarefree numbers can be counted separately from the rest, and this gives a useful check on the arithmetic. Up to 1,000 there are 608 squarefree integers. Each of those contributes either +1 or -1 to the running sum, while every number with a squared prime factor contributes 0. Writing Q+ for the count of squarefree numbers with mu(k) = +1 and Q- for the count with mu(k) = -1, the two parts combine as Q+ - Q- = M(x). For x = 1000 the split works out so that Q+ - Q- equals M(1000) = 2, consistent with the 608 squarefree integers below that bound.

The running sum is what makes the Mertens function interesting. The Mertens conjecture held that |M(x)| < sqrt(x) for every x, and it was disproved in 1985. Even so, M(x) / sqrt(x) stays small in practice: at x = 1000 the ratio is 0.06. A calculator that shows the running sum alongside the individual mu(k) values lets you watch the partial sums rise and fall and see how the final total relates to the squarefree split.

  • Evaluate mu(k) for k = 1 to x: 0 for numbers with a squared prime factor, +1 for an even number of distinct primes, -1 for an odd number.
  • Build the mu table with a linear sieve that records each number's smallest prime factor, then accumulate the running sum as the table is filled.
  • Check the result with the squarefree split Q+ - Q- = M(x); up to 1,000 there are 608 squarefree integers and the split gives M(1000) = 2.
Up to 1,000 there are 608 squarefree integers, and their Mobius signs split so that the +1 count minus the -1 count equals M(1000) = 2.

Values of the Mertens function

The Mertens function is defined as a running sum of the Mobius function: M(x) = mu(1) + mu(2) + ... + mu(x). Each term mu(k) takes one of three values. It is 0 when k has a squared prime factor, +1 when k is a product of an even number of distinct primes, and -1 when k is a product of an odd number of distinct primes. Because M(x) adds these signs together as x grows, its value at any point depends on how the squarefree integers up to that point happen to balance.

At small checkpoints the values of the Mertens function are easy to state and easy to check. M(10) = -1, M(100) = 1 and M(1000) = 2. These three numbers show the pattern that makes the function interesting: it wanders above and below zero rather than growing steadily, and its size stays modest even as x increases by a factor of ten from one checkpoint to the next.

The value at 1,000 can be read directly from the Mobius signs. Up to 1,000 there are 608 squarefree integers; their Mobius signs split so that the +1 count minus the -1 count equals M(1000) = 2. The remaining integers up to 1,000 are not squarefree, so their mu(k) is 0 and they add nothing to the running sum. This is why the count of squarefree numbers and the size of M(x) are related but not identical quantities.

xM(x)M(x) / sqrt(x)
10-1
1001
100020.06
The Mertens conjecture - that |M(x)| < sqrt(x) always - was disproved in 1985, though M(x) / sqrt(x) stays small in practice (0.06 at x = 1000).

The Mertens conjecture and the Riemann hypothesis

The Mertens function M(x) is the running sum of the Mobius function: M(x) = mu(1) + mu(2) + ... + mu(x). Because mu(k) is 0 when k has a squared prime factor, +1 for a product of an even number of distinct primes, and -1 for an odd number, M(x) counts the squarefree integers up to x with signs attached. For example, M(10) = -1, M(100) = 1, and M(1000) = 2. Up to 1,000 there are 608 squarefree integers; their Mobius signs split so that the +1 count minus the -1 count equals M(1000) = 2.

For decades, mathematicians studied how large M(x) can grow. The Mertens conjecture proposed that |M(x)| < sqrt(x) for all x. This bound is remarkably tight: at x = 1000, M(1000) = 2 while sqrt(1000) is about 31.6, so M(x)/sqrt(x) is only about 0.06. The conjecture drew intense interest because it would have implied the Riemann hypothesis, one of the most famous unsolved problems in mathematics. In other words, proving that M(x) never exceeds sqrt(x) in absolute value would have settled the Riemann hypothesis in the affirmative.

That hope collapsed in 1985. Odlyzko and te Riele disproved the Mertens conjecture, showing that |M(x)| < sqrt(x) does not hold for all x. Their proof was indirect: it did not produce an explicit counterexample, meaning no specific value of x was given where the inequality fails. This nonconstructive disproof was a landmark result, demonstrating that the appealingly simple bound is false even though M(x)/sqrt(x) remains small for all x that have been examined.

The story of the Mertens function and the Riemann hypothesis is a cautionary tale about numerical evidence. The first thousand values, with M(x)/sqrt(x) around 0.06, might suggest that the conjecture is true, but the disproof shows that eventually the ratio must exceed 1. Yet the failure is not constructive, so the search for an explicit counterexample continues. Understanding the Mertens function remains valuable because it connects the Mobius function, squarefree integers, and the deepest questions about the distribution of prime numbers.

The Mertens conjecture |M(x)| < sqrt(x) would have implied the Riemann hypothesis, but Odlyzko and te Riele disproved it in 1985 without finding an explicit counterexample.

FAQs

What is the Mertens function?

The Mertens function, written M(x), is the sum of the Mobius function mu(k) over all integers k from 1 to x. Each term mu(k) is either +1, -1 or 0 depending on the factorization of k, so M(x) accumulates those values into a single running total for the range.

What is M(1000)?

M(1000) = 2. That means when you add the Mobius function values mu(k) for every k from 1 through 1000, the net result is 2. The positive and negative contributions nearly cancel, leaving this small total, which is typical of how the Mertens function behaves at larger inputs.

What is M(100)?

M(100) = 1. Summing the Mobius function mu(k) over all k from 1 to 100 gives a net total of 1. As with most values of the Mertens function, the individual +1 and -1 terms largely offset each other, and the final sum stays small relative to the size of the range.

How many squarefree numbers are there up to 1,000?

There are 608 squarefree numbers up to 1,000. Among those, the difference between the count with mu = +1 and the count with mu = -1 is exactly M(1000) = 2. So the two groups of squarefree numbers are almost equal in size, differing by just 2.

Was the Mertens conjecture true?

No. The Mertens conjecture was disproved in 1985 by Odlyzko and te Riele. The conjecture claimed that |M(x)| < sqrt(x) for all x, but their work showed this fails for some x. However, no explicit x violating the bound is known, so the disproof does not hand you a concrete counterexample.

What is M(10)?

M(10) = -1. Adding the Mobius function values mu(k) for k from 1 through 10 gives a net total of -1. This means the negative contributions slightly outweigh the positive ones over that small range, leaving the Mertens function one below zero at x = 10.

Sources

Related calculators

Möbius Function Calculator
The Möbius function mu(n) from the prime factorization of n: zero for a squared prime factor, otherwise plus or minus one by the factor count.
Abundant Number Calculator
Classify any whole number as abundant, perfect or deficient from its aliquot sum: the sum of its proper divisors, the abundance or deficiency against the number itself, and the s(n)/n ratio that puts perfect numbers exactly at one.
Amicable Numbers Calculator
Amicable numbers calculator: test whether two numbers are an amicable pair, with the proper-divisor sums for both numbers shown.