Squarefree Number Calculator

Mobius

is 30 squarefree?Yes - no square above 1 divides it
Mobius function mu(30)-1
largest square divisor1
squarefree count up to 10061
How this was calculated
  1. Factor 30 = 2 x 3 x 5.
  2. A squarefree number has no repeated prime factor - equivalently, no square 4, 9, 16, ... divides it.
  3. No exponent in the factorization exceeds 1, so 30 is squarefree and mu(30) = -1.
  4. Squarefree numbers have density 6 / pi^2 = 0.6079 among the integers - this is a test about n itself, unlike the Mertens function, which sums mu over a whole range.

This Squarefree Number Calculator tells you whether a number is squarefree and shows the answer with its reasoning. A squarefree number has no repeated prime factor, meaning no square above 1 divides it. For example, 30 = 2 x 3 x 5 is squarefree, with Mobius value mu(30) = -1 because it has three distinct prime factors, while 12 is not squarefree because 4 divides it. The calculator also reports how many squarefree numbers fall in a range: there are 61 squarefree numbers up to 100 and 608 up to 1,000, and the density of squarefree numbers tends to 6 / pi^2 = 0.6079.

The method behind the calculator is the accepted standard for this kind of calculation because it works directly from the definition: it factors the number, checks for any repeated prime factor, and applies the Mobius function to distinct prime factors. Counting squarefree numbers is a different job from the Mertens function, which sums the Mobius function over a range, so the two are kept separate here. This page shows the formula, step-by-step workings, worked examples and sources, so you can follow each result rather than take it on trust.

Worked examples

Is 30 squarefree?

(0 - test a single number · 30)

is 30 squarefree?Yes - no square above 1 divides it
Mobius function mu(30)-1
largest square divisor1
squarefree count up to 10061

Is 12 squarefree?

(0 - test a single number · 12)

is 12 squarefree?No - 4 divides it
Mobius function mu(12)0
largest square divisor4
squarefree count up to 10061

Squarefree numbers up to 1,000

(1 - list up to a limit · 1000)

squarefree numbers up to 1,000608
density up to 1,0000.6080
limiting density 6 / pi^20.6079
largest squarefree in range998

What is a squarefree number?

A squarefree number is a whole number that has no repeated prime factor. Another way to say the same thing: no square greater than 1 divides it. These two definitions describe exactly the same set of numbers, which is why you can use whichever one is easier for the problem in front of you. If a prime appears twice in a number's factorization, then that prime squared divides the number, and the number is not squarefree.

Take 30. Its prime factorization is 30 = 2 x 3 x 5. Each prime appears exactly once, so 30 is squarefree. Because it has three distinct prime factors, its Mobius value is mu(30) = -1. Now take 12. Its factorization is 2 x 2 x 3, so the prime 2 is repeated. Equivalently, 4 divides 12, and 4 is a square above 1. Either way you check it, 12 is not squarefree.

The idea shows up in counting questions too. There are 61 squarefree numbers up to 100 and 608 up to 1,000. As the numbers get larger, the share of them that are squarefree settles toward 6 / pi^2 = 0.6079, so a little more than three in five whole numbers are squarefree in the long run. That density is a limit, not an exact count for any particular range, which is why the totals for 100 and 1,000 have to be worked out rather than read off the constant.

One practical note: counting squarefree numbers is a different job from the Mertens function, which sums the Mobius function over a range. The two are related through the Mobius values, but a count of squarefree numbers and a sum of mu values answer different questions, so don't treat one as a substitute for the other.

  • No repeated prime factor: every prime in the factorization appears only once, as in 30 = 2 x 3 x 5.
  • No square divisor above 1: no perfect square such as 4, 9 or 25 divides the number, which is why 12 fails (4 divides it).
  • Mobius link: a squarefree number with an odd number of distinct prime factors, like 30 with three, has mu = -1.
Both definitions agree: 30 = 2 x 3 x 5 is squarefree, while 12 is not, because 4 divides it.

The Mobius connection

The Mobius function, written mu(n), is a small function with a large reach. It takes only three values: 0, 1, and -1. The rule is simple. If n is not squarefree, mu(n) is 0. If n is squarefree, mu(n) is +1 or -1, and the sign is set by the parity of the prime factor count: an even number of distinct primes gives +1, an odd number gives -1. So the Mobius function is a compact way of recording two things at once — whether a squarefree number is involved, and how many distinct primes it has.

A worked example makes the rule concrete. The number 30 equals 2 x 3 x 5. It has three distinct prime factors and no repeats, so it is squarefree, and because three is odd, mu(30) = -1. The number 12 is not squarefree because 4 divides it; its prime factorization is 2 x 2 x 3, with the factor 2 repeated. Under the rule, mu(12) = 0. That zero is not a judgment about size or importance. It simply marks that 12 fails the squarefree test, and the Mobius function has nothing further to say about it.

This is why the Mobius function and the idea of a squarefree number are so tightly linked. The zeros of mu(n) are exactly the numbers that are not squarefree, and the nonzero values are exactly the squarefree ones, split into two equal-looking camps by parity. Checking whether a number is squarefree can therefore be phrased as asking whether mu(n) is nonzero. The two questions are the same question wearing different clothes.

It is worth separating two jobs that sound similar but are not. Counting squarefree numbers in a range means tallying how many n have mu(n) not equal to 0. The Mertens function does something different: it sums the Mobius function itself over a range, so the +1 and -1 values partially cancel and the zeros drop out of the total. A count and a sum can give very different pictures of the same stretch of numbers.

For context on how common these numbers are, there are 61 squarefree numbers up to 100 and 608 up to 1,000. As the range grows, the density of squarefree numbers tends to 6 / pi^2, which is about 0.6079. The Mobius function is the tool that makes those counts expressible: mu(n) is nonzero precisely when n is squarefree, and its sign tells you the parity of the distinct prime factors behind it.

mu(n) = 0 when n is not squarefree; otherwise mu(n) is +1 or -1 by the parity of the distinct prime factor count. Example: mu(30) = -1 because 30 = 2 x 3 x 5 has three distinct primes.

How many squarefree numbers are there?

Counting squarefree numbers is a matter of asking, for a given limit, how many integers up to that limit have no repeated prime factor. The counts grow steadily but never keep pace with the integers themselves, because a fixed share of numbers is always lost to divisibility by a square above 1. The two benchmark counts are 61 squarefree numbers up to 100 and 608 up to 1,000.

The table below sets out those two figures side by side. The second column shows the count, and the third shows that count as a share of all the integers from 1 to the limit. Up to 100, the squarefree numbers are a little over six in ten; up to 1,000, the share is close to the same figure. That stability is the point of the table: the proportion does not drift away as the limit rises.

The limiting density of squarefree numbers is 6 / pi^2, which equals 0.6079. In other words, as the limit grows, the fraction of integers that are squarefree settles toward roughly 60.79 percent. The counts of 61 and 608 are consistent with that limit, and the density is the clean statement of what the counts are approaching. A number like 30 = 2 x 3 x 5 is squarefree, with three distinct prime factors and a Mobius value of mu(30) = -1, while 12 is not squarefree because 4 divides it. Each excluded square removes a predictable slice of the integers, and the combined effect of all those slices is the 6 / pi^2 limit.

Counting squarefree numbers is a different job from the Mertens function, which sums the Mobius function over a range. The squarefree count asks only whether each integer has a repeated prime factor; the Mertens sum adds up signed values that depend on how many distinct prime factors each number has. Keeping the two apart matters when you read or check a result, because they answer different questions even though both draw on the same underlying structure of prime factors.

LimitSquarefree numbers up to the limitShare of integers
1006161 / 100 = 0.61
1,000608608 / 1,000 = 0.608
The density of squarefree numbers tends to 6 / pi^2 = 0.6079, so about 60.79 percent of integers are squarefree in the limit.

Squarefree counting vs the Mertens function

A squarefree number has no repeated prime factor: no square above 1 divides it. That single definition drives two related but distinct jobs on this site. This page tests individual numbers and counts how many squarefree values fall in a range. The Mertens function page does something different: it sums the Mobius function over a range. Keeping the two apart helps you read each result correctly and pick the tool that answers your actual question.

The test itself is simple to state. For 30 = 2 x 3 x 5, the three prime factors are all distinct, so 30 is squarefree, and its Mobius value is mu(30) = -1 because it has three distinct prime factors. For 12, the factor 4 divides it, so 12 is not squarefree. In counting mode, the same test runs across every integer in your range and tallies the ones that pass. The published figures for this count are 61 squarefree numbers up to 100 and 608 up to 1,000. As the range grows, the density of squarefree numbers tends to 6 / pi^2 = 0.6079, so the count approaches roughly 60.79 percent of the integers considered.

The Mertens function answers a different question. Instead of asking how many integers are squarefree, it adds up the Mobius function values across the range. Each squarefree number contributes either +1 or -1 depending on its number of distinct prime factors, as with mu(30) = -1, and each number that is not squarefree contributes 0. The running total can rise, fall, and cross zero, so its value at the end of a range is not a count of anything. A large positive or negative total tells you how the +1 and -1 contributions balanced out, not how many squarefree numbers you passed.

That difference matters when you check a result. If you want to know how many squarefree numbers lie up to 1,000, the answer is a count such as 608, and the Mertens total for the same range will not match it. If you want the summed Mobius value, the count is the wrong figure. Use this page for the per-number test and the range count, and use the Mertens function page when you need the sum of mu over the range. Both rely on the same underlying test for whether a squarefree number is present, but they report it in different forms.

Same test, different output: this page counts squarefree numbers, while the Mertens function page sums mu over the range. A count like 61 up to 100 is not the Mertens total for that range.

FAQs

What is a squarefree number?

A squarefree number is an integer that is not divisible by any square greater than 1. Equivalently, it is a number with no repeated prime factor, so every prime in its factorization appears only once. For example, 30 qualifies because its prime factors 2, 3 and 5 each appear exactly once.

Is 30 squarefree?

Yes. The number 30 factors as 2 x 3 x 5, and all exponents are 1, so no square greater than 1 divides it. Its Mobius value is -1, which fits the rule for a squarefree number with an odd number of distinct prime factors. Here that count is three.

Is 12 squarefree?

No. The number 4 divides 12, so 12 is divisible by a square greater than 1 and is therefore not squarefree. Its prime factorization repeats the factor 2. Because of this, the Mobius function of 12 equals 0, which is the value assigned to any number that is not squarefree.

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

There are 608 squarefree numbers up to 1,000. That count covers the integers from 1 through 1,000 that are not divisible by any square greater than 1. The remaining numbers in that range fail the test because some square greater than 1 divides them.

What fraction of numbers are squarefree?

Roughly three in five. The density of squarefree numbers tends to 6 / pi^2 = 0.6079, so about 60.79 percent of integers are squarefree. This proportion holds as a limiting density over larger and larger ranges, not as an exact count for every range.

What is the Mobius function of a squarefree number?

For a squarefree number, the Mobius function is plus 1 when the number has an even number of distinct prime factors, and minus 1 when that count is odd. When the number is not squarefree at all, the Mobius function is 0. So the value depends on the parity of the distinct prime factors.

Sources

Related calculators

Mertens Function Calculator
The Mertens function M(x), the running sum of the Mobius function, with mu(x), the squarefree count Q(x) and the split of squarefree numbers by Mobius sign.
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.
Carmichael Number Calculator
Test whether a number is a Carmichael number with Korselt's criterion - squarefree with p - 1 dividing n - 1 for every prime factor - and see its full factorization.