gives True if expr is a square-free polynomial or number, and False otherwise.


gives True if expr is square-free with respect to the variables vars.

Details and Options

  • SquareFreeQ is typically used to test whether a number or a polynomial is square free.
  • An integer n is square free if it is divisible by no perfect square other than 1.
  • SquareFreeQ[expr] returns False unless expr is manifestly square free.
  • With the setting GaussianIntegers->True, SquareFreeQ tests whether expr is Gaussian square free.
  • For integers m and n, SquareFreeQ[m+I n] automatically works over Gaussian integers.
  • The following options can be given:
  • GaussianIntegersAutomaticwhether to allow Gaussian integers
    Modulus0modulus for polynomial coefficients


open allclose all

Basic Examples  (2)

Test whether a number is square free:

The number 4 is not square free:

Scope  (5)

SquareFreeQ works over integers:

Gaussian integers:

Rational numbers:

Univariate polynomials:

Multivariate polynomials:

Specify the variable in a polynomial:

Polynomials over a finite field:

Test for large integers:

Options  (2)

GaussianIntegers  (1)

Test whether 2 is square free over integers:

Gaussian integers:

Modulus  (1)

Test whether is square free over integers:

Integers modulo 3:

Applications  (8)

Basic Applications  (3)

Highlight square-free numbers:

Generate random square-free integers:

Square-free Gaussian integers:

Number Theory  (5)

The central binomial coefficients Binomial[2n,n] are not square free for :

Find the fraction of the first numbers that are square free:

The result is close to :

The polynomial p[x]/PolynomialGCD[p[x],p'[x]] is always square free:

The distribution of square-free numbers over integers:

Plot the distribution:

The distribution of square-free numbers over the Gaussian integers:

Plot the distribution:

Properties & Relations  (8)

A number that is divisible by a square is not square free:

In the prime factorization of a square-free number, the exponents of primes are all 1:

PrimeNu is equal to PrimeOmega for square-free numbers:

MoebiusMu is zero for non-square-free integers:

Numbers that are prime powers and square free are prime numbers:

The discriminant of a quadratic non-square-free polynomial is 0:

Square factors can be found using FactorSquareFreeList:

Simplify symbolic expressions:

Neat Examples  (3)

Plot the prime numbers that are the sum of three squares:

Square-free Gaussian integers:

Plot the Ulam spiral of square-free numbers:

Introduced in 2007