C has sqrt() and cbrt(), but those are only the second and third roots. What if the root is an arbitrary number? What if I need the 57nth root?
C has sqrt() and cbrt(), but those are only the second and third roots. What if the root is an arbitrary number? What if I need the 57nth root?
Use the pow function, taking advantage of the fact that getting the 57 root is the same as raising to the power of 1 / 57.
More generically, to get the y root of x:
double result = pow(x, 1.0 / y);
You should the pow(x,n) function instead.
The function definition is as the following: double pow(double x, double y)
So, in that case above, you should write
pow(x, 1.0/57.0);