Task

Implement the algorithm to compute the principal   nth   root   





A

n





{\displaystyle {\sqrt[{n}]{A}}}

   of a positive real number   A,   as explained at the   Wikipedia page.



F nthroot(a, n)
   V result = a
   V x = a / n
   L abs(result - x) > 10e-15
      x = result
      result = (1.0 / n) * (((n - 1) * x) + (a / pow(x, n - 1)))
   R result
 
print(nthroot(34.0, 5))
print(nthroot(42.0, 10))
print(nthroot(5.0, 2))