RosettaCodeData/Task/Nth-root/MATLAB/nth-root-1.m

14 lines
254 B
Mathematica
Raw Permalink Normal View History

2013-04-10 23:57:08 -07:00
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