14 lines
277 B
Text
14 lines
277 B
Text
nthRoot: function [a,n][
|
|
N: to :floating n
|
|
result: a
|
|
x: a / N
|
|
while [0.000000000000001 < abs result-x][
|
|
x: result
|
|
result: (1//n) * add (n-1)*x a/pow x n-1
|
|
]
|
|
return result
|
|
]
|
|
|
|
print nthRoot 34.0 5
|
|
print nthRoot 42.0 10
|
|
print nthRoot 5.0 2
|