Skip to content
OneKitly

A Function That Only Ever Answers −1, 0 or 1

Published 10/27/2026 · 4 min read · Everyday calculators

Lena Hoffmann

Lena Hoffmann — Science & education writer at OneKitly

Mathematics · Physics

Checked against 2 sources

View profile →
In short

The rule has two branches. If any prime divides the number twice, the answer is 0 — that is why 12 = 2² × 3 and 49 = 7² both return zero. Otherwise the answer is −1 when the number of distinct primes is odd and 1 when it is even: 30 = 2 × 3 × 5 has three primes and gives −1, while 6 = 2 × 3 has two and gives 1. One returns 1, the empty product having zero primes. About 39 % of numbers hit the zero branch — among the first hundred, exactly 39 do — because the density of numbers free of a repeated prime factor is 6/π², or 60.8 %.

Advertisement

The Möbius function returns 0 for 12 and 49, −1 for 30 and 105, and 1 for 6. Three possible answers encode the entire factorisation pattern of a number.

The zero is not a failure, it is the point

It is tempting to read the zero as a missing value, the way a division by zero is undefined. It is nothing of the kind: the zero is a deliberate answer that switches a term off. The function's purpose is to appear inside sums over the divisors of a number, where the terms are meant to cancel each other except for one survivor. Sum the answers over the divisors of 30 — that is 1, 2, 3, 5, 6, 10, 15 and 30 — and the total is exactly zero, the +1 and −1 contributions cancelling in pairs. That cancellation is the engine behind a family of inversion formulas that recover a quantity from its cumulative totals.

Where the three answers turn up in practice

The most familiar appearance is counting sequences that do not repeat. Ask how many necklaces of a given length can be made from a fixed alphabet without any of them being a shorter pattern copied over and over, and the answer is a sum over divisors with these three coefficients steering it. The same shape governs how many irreducible polynomials of a given degree exist over a finite field, a count that matters when choosing parameters for error-correcting codes. In each case the −1 subtracts the degenerate configurations that were double-counted, and the 0 quietly skips the divisors that would subtract them twice.

Answer
Six numbers and their answers
NumberFactorsAnswer
1none1
62 × 31
122² × 30
302 × 3 × 5−1
497²0
1053 × 5 × 7−1
Möbius function calculator μ(n)The Möbius function μ(n) is 0 if n has a squared prime factor, otherwise +1 or −1 for an even or odd number of distinct prime factors. Enter n and get μ(n) with its prime factorisation and whether n is squarefree.Try the tool →
Advertisement

Frequently asked questions

Why is the answer for 1 equal to 1 and not 0?
Because one has no prime factors at all, and zero is an even count. The rule says even means 1, so one returns 1 without any special case being written for it. That is not an arbitrary convention chosen to be tidy — it is forced by the sums the function is built to serve. If one returned 0 instead, every divisor sum would lose its leading term and none of the inversion formulas would work. The empty product answering 1 is the same convention that makes a number raised to the power zero equal one.
Do the +1 and −1 answers balance out in the long run?
They appear to, and how closely they do is one of the deepest open questions in the subject. Add the answers for every number up to some limit and the running total wanders around zero rather than drifting off, as a fair coin's tally would. Proving that the wandering stays within a specific bound — roughly the square root of the limit — is equivalent to the Riemann hypothesis, so the balance you can watch on a calculator in ten seconds is the same statement that has resisted proof since 1859. An earlier and stronger guess about that bound was disproved in 1985, which is a useful reminder that a pattern holding for millions of cases is not an argument.

Articles you may find interesting

All guides →

Related tools

Sources

Spotted a mistake in this article?