Mobius Function Calculator

This Mobius function calculator computes mu of n, a function at the heart of analytic number theory. The rule is simple: mu(n) is 0 if n is divisible by the square of any prime, otherwise it is plus 1 if n has an even number of distinct prime factors and minus 1 if it has an odd number, with mu(1) defined as 1. Enter a number up to a billion and the calculator returns mu(n), whether n is squarefree, and its count of distinct primes. The Mobius function powers Mobius inversion, links to the distribution of primes through the Riemann zeta function, and appears throughout combinatorics. The definition, a worked example and the assumptions are set out below.

Conservation Amendment Bill
 
Squarefree? 
Distinct prime factors 

The formula

mu(1) = 1. If n has a squared prime factor, mu(n) = 0. Otherwise mu(n) = (minus 1) to the power k, where k is the number of distinct prime factors. So squarefree numbers give plus or minus 1, by parity.

Worked example

30 = 2 times 3 times 5, three distinct primes and squarefree, so mu(30) = (minus 1) cubed = minus 1. But 12 = 2 squared times 3 has a squared factor, so mu(12) = 0. Enter 30 to confirm.

Frequently asked questions

What does the Mobius function do?

It returns 0 for numbers with a squared prime factor, and plus or minus 1 for squarefree numbers depending on whether they have an even or odd number of prime factors.

What is a squarefree number?

One not divisible by any perfect square above 1, equivalently no prime appears twice in its factorisation.

Where is it used?

In Mobius inversion, in counting problems, and in deep links between primes and the Riemann zeta function.

Who this calculator is for

This calculator is for students, programmers and anyone exploring number theory.

What this calculator assumes

  • You enter a whole number within the stated range.
  • The exact integer algorithm is used.
  • Very large results are shown grouped for readability.

Formula and sources

Related calculators

If you've found a bug, or would like to contact us, or learn more about James Graham and Calculate.co.nz.

Calculate.co.nz is partnered with Interest.co.nz for New Zealand's highest quality calculators and financial analysis.

All calculators and tools are provided for educational and indicative purposes only and do not constitute financial advice.

Calculate.co.nz is proudly part of the Realtor.co.nz group, New Zealand's leading property transaction literacy platform, helping Kiwis understand the home buying and selling process from start to finish. Whether you're a first home buyer navigating your first property purchase, an investor evaluating your next acquisition, or a homeowner planning to sell, Realtor.co.nz provides clear, independent, and trustworthy guidance on every step of the New Zealand property transaction journey.

Calculate.co.nz is also partnered with Health Based Building and Premium Homes to promote informed choices that lead to better long-term outcomes for Kiwi households.

Calculate.co.nz is hosted in Auckland via SiteHost new Zealand.

All content on this website, including calculators, tools, source code, and design, is protected under the Copyright Act 1994 (New Zealand). No part of this site may be reproduced, copied, distributed, stored, or used in any form without prior written permission from the owner.

About & trust: Why Calculate is NZ's most comprehensive · By the Numbers · How we compare · Editorial standards · How we keep data current · NZ finance glossary · Research & data · Financial literacy NZ · About · Privacy policy · Terms of use

Reviewed and maintained. Last reviewed 2026-06-21 and checked on a twice-monthly cycle against IRD, RBNZ and Stats NZ. How we keep data current.

© 2026 Calculate.co.nz. All rights reserved. Building free NZ calculators since 2011.