[Math] finding the greatest perfect square dividing an integer

number theoryprime numbers

how can we find the greatest integer which is a perfect square and which divides an integer? I believe factorisation can be used here but am not sure how to get the result out of it for all prime, non-prime, and also integers which are themselves perfect square(e.g 1296) ?
Thanks.

Best Answer

Say that you are given the integer $n$ and want to find the largest perfect square $k$ such that $k \mid n$.

First, find the prime factorization of $n$: $$n = p_1^{e_1} \cdots p_m^{e_m}$$ Let $$k = p_{1}^{e_1'} \cdots p_{m}^{e_m'}$$ where $e_m'$ is the largest even integer smaller than or equal to $e_m$, which will make $k$ the largest perfect square which divides $n$.

For example $$1296 = 2^4 \cdot 3^4$$ and both exponents are even, so you get the same number.

Since $$1 609 699 = 7^3 \cdot 13 \cdot 19^2$$ the largest perfect square which divides this is $7^2 \cdot 19^2 = 17689$.

And $$3458 = 2 \cdot 7 \cdot 13 \cdot 19$$ has no exponents larger than one, so the largest perfect square which divides it is 1.

Related Question