Simplifying Radical Expressions
Better approach

First, if you got rid of all floating point and just use long, that would fix your inaccuracy problems.

Second, your loop is trying to find the greatest factor of the number that is a square.  But for a large number it will run for a long time because you check every number up to \$\sqrt n\$.  You can shorten the time by dividing any factors you find along the way.  For example, if 2 divides into \$n\$ 7 times, then \$2^3\$ can be factored out of the square root  and \$2\$ will remain under the radical.  I.e.:

If: \$n = 2^7 * m\$
\$\sqrt n = 2^3 \sqrt {2 * m}\$

If a factor divides an even number of times into your number, then it can be pulled out without leaving anything under the radical.

After you simplify for each factor, you keep going to find factors of \$m\$, which is smaller, so you only need to check factors up to \$\sqrt m\$.  You just need to keep track of the internal and external factors as you go.

In the worst case (if the number is prime), it will still take the same amount of time.  You could research factorization algorithms if you want something better.