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.



fcn nthroot(nth,a,precision=1.0e-5){
   x:=prev:=a=a.toFloat(); n1:=nth-1;
   do{
      prev=x;
      x=( prev*n1 + a/prev.pow(n1) ) / nth;
   }    
   while( not prev.closeTo(x,precision) );
   x 
}
 
nthroot(5,34) : "%.20f".fmt(_).println()  # => 2.02439745849988828041