2

Given a number $n$. I need to find the largest $q$ such that $q^2$ divides $n$. I need the fastest method to find $q$. $q$ can be any number prime or composite.

At present I am factorizing the number $n$ to find the highest number $q$. I need a better approach which does not involve to factorize the number $n$ completely or by some other approach which is less than $O(\sqrt n)$. Constraint: $n\leq 10^{18}$

some test cases:

  • if $n=180$ then $q=6$
  • if $n=17$ then $q=1$
  • if $n=10000$ then $q=100$
user157920
  • 109
  • 6
  • 2
    Is there a reason you think there is such an algorithm? – Thomas Andrews Jul 19 '14 at 14:27
  • I think you still need to break down that number by the multipliers. And then to make up the number. Using multipliers. Which Degree a multiple of 2. – individ Jul 19 '14 at 15:09
  • 1
    @individ I already did this but this approach times out i.e why I asked for the better approach – user157920 Jul 19 '14 at 15:56
  • 1
    @ThomasAndrews those who did this question didn't factorize n completely so that is why i thought if there is a such an algorithm. – user157920 Jul 19 '14 at 15:57
  • @barto when you edit a post, consider giving it a title better than "need help in number theory problem" –  Jan 24 '15 at 20:38
  • @user157920 It is possible to factor $n$ in much faster time than $O(\sqrt{n})$. Don't assume other people didn't factor $n$. – Erick Wong Jan 24 '15 at 20:41
  • the method discussed in the following link seems to determine if a number is square-free using the two squares representation of an integer N.
    https://math.stackexchange.com/questions/3064068/can-the-sum-of-two-squares-be-used-to-determine-if-a-number-is-square-free?rq=1
    – user25406 Jan 27 '19 at 21:48

1 Answers1

8

It is trivial to to compute square/squarefree parts if we are given the prime factorization. Currently we do not know any better way, and it is widely suspected that there is none, i.e the problem may prove to be equivalent to factorization.

This problem is important because one of the main tasks of computational algebraic number theory reduces to it (in deterministic polynomial time). Namely the problem of computing the ring of integers of an algebraic number field depends upon the square-free decomposition of the polynomial discriminant (when computing an integral basis).

Contrast this difficulty with the trivial squarefree decomposition of polynomials by way of gcd with its derivative. The availability of derivatives for polynomials opens up a powerful toolbox that is not available for integers. For example once derivatives are available so are Wronskians - which provide powerful measures of dependence in transcendence theory and diophantine approximation. A simple yet stunning example is the elementary proof of Mason's ABC theorem for polynomials, which yields as a very special case a high-school-level proof of FLT for polynomials.

For references see my post here.

Bill Dubuque
  • 272,048