11 lines
244 B
Text
11 lines
244 B
Text
F nthroot(a, n)
|
|
V result = a
|
|
V x = a / n
|
|
L abs(result - x) > 10e-15
|
|
x = result
|
|
result = (1.0 / n) * (((n - 1) * x) + (a / pow(x, n - 1)))
|
|
R result
|
|
|
|
print(nthroot(34.0, 5))
|
|
print(nthroot(42.0, 10))
|
|
print(nthroot(5.0, 2))
|