### Need a Perfect Square Factorer

I'm having trouble with a function of mine. It is supposed to factor out all the perfect squares within a number. For example, say the number was 24160, I need the program to factor out 16 as the perfect square and leave 1510 as the other part.

Here's what I have so far:

 ``1234567891011121314151617181920`` ``````//getSimplifiedRad function void getSimplifiedRad(double squareRoot, double &endRad, double &outRad) { //Begin loop for (int simplifier = 2; simplifier * simplifier <= squareRoot; simplifier++) { //Simplifier will always be a perfect square if (getIsPrime(squareRoot/(simplifier*simplifier)) == true) { squareRoot /= (simplifier * simplifier); if (getIsPrime(squareRoot) == true && getIsPerfSquare(simplifier) == true) { endRad = squareRoot; outRad = simplifier; }//End if }//End if }//End for loop } //End of getSimplifiedRad function ``````

(Yes, this is for a quadratic equation program)

This has been giving me trouble for a while, and I have re-written it twice.
Thanks!
Last edited on
Topic archived. No new replies allowed.