Factoring nth root numbers

closed account (y0q21hU5)
I am working on a project where I am passed a nth root. I then have to factor out any squares(or cubes or higher if it were not just a square root). For instance sqrt(84) would become 2*sqrt(21). I am factoring the 84 out and placing all the factors into a vector. Back to the case of sqrt(84): I would have a vector containing <2,2,3,7>. From there I am not sure where to go. I know I have to find out how many times each element in the vector appears, but I am not sure how to do this. If it appears n amount of times then I can factor it out. I am just not sure how to keep track of how many times each element appears. Any help would be great. Thanks!

First ensure that the vector is sorted. Start from the top and count from zero. If this element is different from the last, the count is the power of the last prime; reset the count to 1. If the element is equal, increment the count.
Topic archived. No new replies allowed.