Mertens Function
Return M(n)=Σ(k≤n)μ(k) exactly by sieving distinct prime factors and square factors, with M(0)=0 and n capped at 1,000,000.
Description
Mertens’ function is the cumulative sum of Möbius values.
Mertens’ function is the cumulative sum of Möbius values. Square factors contribute zero, while square-free integers contribute signs determined by their number of distinct prime factors.1
The tool returns value. The indexing and output conventions below determine how to read these values.
When to use Mertens Function
Use this for the following task: Return M(n)=Σ(k≤n)μ(k) exactly by sieving distinct prime factors and square factors, with M(0)=0 and n capped at 1,000,000. Use the input and output conventions below to reproduce the intended mathematical quantity.
How to use Mertens Function and understand its results
- Choose the required indexes, integers or sequence entries. Preserve decimal-string encodings where the field table specifies strings.
- Enter n according to the field table, then run the tool.
- Read value. Use the stated units, indexing and interpretation of the numerical result.
- Keep exact decimal strings for subsequent integer arithmetic; distinguish them from any explicitly approximate numeric result.
| Input field | Meaning | Value type and bounds | Requirement |
|---|---|---|---|
| n | Nonnegative summation limit (sieve resource limit 1000000) | integer; minimum 0; maximum 1000000 | Required |
Sieve primes through n, flip signs at multiples of each prime and set multiples of prime squares to zero. Sum the resulting Möbius values through the inclusive limit.
M(n)=Σ[k=1..n]μ(k) The symbols and boundary conditions refer to the supplied fields and the implementation described above.
| Output field | Meaning | Value type |
|---|---|---|
| value | Mertens summatory Möbius value | integer |
{
"input": {
"n": 10
},
"output": {
"value": -1
}
} Limitations and assumptions
The limit is at most one million and M(0)=0. A finite computed prefix does not establish bounds or conjectures about the function at larger inputs.
Use the declared integer bounds and string formats. Large exact outputs remain decimal strings; numerical approximations use ordinary floating-point arithmetic. A rejected input is different from a valid zero count or false membership flag.
Alternative or Complementary methods
Choose Liouville Lambda Function when you need its operation: Return λ(n)=(−1)^Ω(n), counting prime factors with multiplicity and using λ(1)=1; trial division is limited to n≤10¹². Choose Möbius Inversion of Divisor Sums for the complementary operation: Recover f(1)…f(N) from F(n)=Σ(d|n)f(d) by exact triangular divisor-sum inversion; prefixes start at one and are capped at 1,000 entries.
Background reference: OEIS A002321.
References
-
OEIS A002321 — OEIS Foundation
Similar or alternative tools
- Liouville Lambda Function
Return λ(n)=(−1)^Ω(n), counting prime factors with multiplicity and using λ(1)=1; trial division is limited to n≤10¹².
- Möbius Inversion of Divisor Sums
Recover f(1)…f(N) from F(n)=Σ(d|n)f(d) by exact triangular divisor-sum inversion; prefixes start at one and are capped at 1,000 entries.