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.



/* Finds the N-th root of the number A */
root: procedure (A, N) returns (float);
   declare A float, N fixed binary;
   declare (xi, xip1) float;
 
   xi = 1; /* An initial guess */
   do forever;
      xip1 = ((n-1)*xi + A/xi**(n-1) ) / n;
      if abs(xip1-xi) < 1e-5 then leave;
      xi = xip1;
   end;
   return (xi);
end root;