I use the method below to calculate the Nth Root of a double value, but it takes a long time to calculate the 240th root. I learned about the Newton method, but could not implement it in a method with limited programming skills, I would be grateful for any help.
static double NthRoot(double A, int N) { double epsilon = 0.00001d;// double n = N; double x = A / n; while (Math.Abs(A-Power(x,N)) > epsilon) { x = (1.0d/n) * ((n-1)*x + (A/(Power(x, N-1)))); } return x; }
static double NthRoot(double A, int N) { return Math.Pow(A, 1.0 / N); }
From Wikipedia :
In calculus, roots are considered as special cases of exponentiation, where the exponent is a fraction:
\sqrt[n]{x} \,=\, x^{1/n}