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.



function answer = nthRoot(number,root)
 
    format long
 
    answer = number / root;
    guess = number;
 
    while not(guess == answer)
       guess = answer;
       answer = (1/root)*( ((root - 1)*guess) + ( number/(guess^(root - 1)) ) ); 
    end
 
end