RosettaCodeData/Task/Nth-root/Octave/nth-root-2.octave
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

12 lines
215 B
Text

function r = m_nthroot(n, A)
x0 = A / n;
m = n - 1;
while(1)
x1 = (m*x0 + A./ x0 .^ m) / n;
if ( abs(x1-x0) < abs(x0 * 1e-9) )
r = x1;
return
endif
x0 = x1;
endwhile
endfunction