Skip to content

IsSquareFree ​

Tests whether n has no repeated prime factors.

✓ checked against that system · ! checked, with disagreements (hover a chip)WikipediaSquare-free integerMathWorldSquarefreeWikidataQ50706OEISA005117Wolfram LanguageSquareFreeQ!
IsSquareFree(n)tests whether nn has no repeated prime factor.
SageMathis_squarefree(n)Juliais_squarefree(ZZ(n))Rustis_square_free(n)
IsSquareFree(f)for a polynomial ff, whether it has no repeated irreducible factor.
SageMathis_squarefree(f)Juliais_squarefree(ZZ(f))Rustis_square_free(f)
IsSquareFree(f, x)whether ff has no repeated factor as a polynomial in xx alone.
Typed signatures
TypePackageApplies
(expression | number | quadratic_integer, any*) -> booleannumber-theoryreplaces compute-enginealways
(integer) -> booleancompute-enginealways

Domain: Number theory

Details
  • An integer is squarefree if it is divisible by no perfect square other than 1.
  • Every prime is squarefree; 1 is vacuously squarefree.
  • Equivalent to μ(n)≠0\mu(n)\neq0. See MoebiusMu.
  • Returns False unless nn is provably squarefree.

Examples

5 more kept as data, checked against the oracles
Basic #
live ↗
InIsSquareFree(10)\mathrm{IsSquareFree}(10)OutTrue\mathrm{True}
live ↗
InIsSquareFree(4)\mathrm{IsSquareFree}(4)OutFalse\mathrm{False}
live ↗
InIsSquareFree(12)\mathrm{IsSquareFree}(12)OutFalse\mathrm{False}

Every prime is squarefree

live ↗
InIsSquareFree(17)\mathrm{IsSquareFree}(17)OutTrue\mathrm{True}
live ↗
InIsSquareFree(20)\mathrm{IsSquareFree}(20)OutFalse\mathrm{False}
Scope #

Threads element-wise over a list

live ↗
InIsSquareFree([10,4,12])\mathrm{IsSquareFree}(\bigl\lbrack10, 4, 12\bigr\rbrack)Out[True,False,False]\bigl\lbrack\mathrm{True}, \mathrm{False}, \mathrm{False}\bigr\rbrack

Gaussian integers: 3+2i3+2i is a Gaussian prime

live ↗
InIsSquareFree(3+2i)\mathrm{IsSquareFree}(3+2i)OutTrue\mathrm{True}

GaussianIntegers -> True: 2=−i(1+i)22=-i(1+i)^2

live ↗
InIsSquareFree(2,Rule(Over,GaussianIntegers))\mathrm{IsSquareFree}(2, \mathrm{Rule}(\mathrm{Over}, \mathrm{GaussianIntegers}))OutFalse\mathrm{False}

Rationals: numerator and denominator are both squarefree

live ↗
InIsSquareFree(23)\mathrm{IsSquareFree}(\frac{2}{3})OutTrue\mathrm{True}

Polynomials: x2+6x+6x^2+6x+6 has no repeated factor -- decided by gcd⁡(f,f′)\gcd(f, f') via D and compute-engine's own PolynomialGCD

live ↗
InIsSquareFree(x2+6x+6)\mathrm{IsSquareFree}(x^2+6x+6)OutTrue\mathrm{True}

Multivariate: x3−x2y=x2(x−y)x^3-x^2y=x^2(x-y), a repeated factor of xx

live ↗
InIsSquareFree(x3−x2y)\mathrm{IsSquareFree}(x^3-x^2y)OutFalse\mathrm{False}

Squarefree as a polynomial in xx alone -- yy is just a coefficient here

live ↗
InIsSquareFree(xy2,x)\mathrm{IsSquareFree}(xy^2, x)OutTrue\mathrm{True}

…but not in yy alone: yy appears squared

live ↗
InIsSquareFree(xy2,y)\mathrm{IsSquareFree}(xy^2, y)OutFalse\mathrm{False}

A 71-digit integer tested exactly

live ↗
InIsSquareFree(3+1070)\mathrm{IsSquareFree}(3+10^{70})OutTrue\mathrm{True}

A prime is squarefree

live ↗
InIsSquareFree(2)\mathrm{IsSquareFree}(2)OutTrue\mathrm{True}

Also accepts polynomials

live ↗
InIsSquareFree(x2−3)\mathrm{IsSquareFree}(x^2-3)OutTrue\mathrm{True}
Applications #
live ↗
InN(1100 000Length(Filter(1..100 000,IsSquareFree)))N(\frac{1}{100\,000}\mathrm{Length}(\mathrm{Filter}(1..100\,000, \mathrm{IsSquareFree})))Out0.000 01Length(Filter(1..100 000,IsSquareFree))0.000\,01\mathrm{Length}(\mathrm{Filter}(1..100\,000, \mathrm{IsSquareFree}))
live ↗
InIsSquareFree(q)\mathrm{IsSquareFree}(q)OutTrue\mathrm{True}
Properties #

nn is squarefree exactly when μ(n)≠0\mu(n)\neq0. See MoebiusMu

live ↗
InIsSquareFree(10)=¬(MoebiusMu(10)=0)\mathrm{IsSquareFree}(10)=¬(\mathrm{MoebiusMu}(10)=0)OutTrue\mathrm{True}

210=2⋅3⋅5⋅7210=2\cdot3\cdot5\cdot7, no repeated prime

live ↗
InIsSquareFree(210)\mathrm{IsSquareFree}(210)OutTrue\mathrm{True}

14=2⋅714=2\cdot 7, no repeated prime

live ↗
InIsSquareFree(14)\mathrm{IsSquareFree}(14)OutTrue\mathrm{True}

Primes are squarefree

live ↗
InIsPrimePower(17)∧IsSquareFree(17)\mathrm{IsPrimePower}(17)∧\mathrm{IsSquareFree}(17)OutTrue\mathrm{True}

(x−1)2(x-1)^2 has a repeated factor

live ↗
InIsSquareFree(x2−2x+1,x)\mathrm{IsSquareFree}(x^2-2x+1, x)OutFalse\mathrm{False}

A square of an integer is not squarefree, given a∈Za\in\mathbb Z

live ↗
InSimplify(IsSquareFree(a2),a∈Z)\mathrm{Simplify}(\mathrm{IsSquareFree}(a^2), a∈ℤ)OutFalse\mathrm{False}

Expanding does not hide the repeated factors

live ↗
InIsSquareFree(Expand((x+1)3(x+2)2(x+3)2))\mathrm{IsSquareFree}(\mathrm{Expand}((x+1)^3(x+2)^2(x+3)^2))OutFalse\mathrm{False}
Possible issues #

1 is vacuously squarefree: it has no repeated prime factors

live ↗
InIsSquareFree(1)\mathrm{IsSquareFree}(1)OutTrue\mathrm{True}
About
Examples31
Checked againstWolfram Language 27 agree2 differSageMath 14 agree1 differ7 errorSymPy 18 agree4 differ3 errormathlib4 10 agree4 errorJulia 12 agree3 errorRust 10 agree4 error
CrosswalkWikipediaMathWorldWikidataOEISWolfram LanguageSageMathJuliaRust

Implementation

mappedsagepackages/oracle/src/mappings.ts
mappedjuliapackages/oracle/src/mappings.ts
mappedrustpackages/oracle/src/mappings.ts

Every exponent of the factorization is 1.

mappedsympypackages/oracle/src/mappings.ts
mappedmathlib4packages/oracle/src/mappings.ts

Squarefree on the natural numbers, so Squarefree 0 is false and a negative n fails to typecheck.

See also: MoebiusMu, FactorInteger