prime factorization to simplify the square root