Nth root: Difference between revisions

20 bytes removed ,  25 days ago
Line 2,370:
 
{{trans|D}}
<syntaxhighlight lang="langur">writeln "operator"
writeln "operator"
writeln (7131.5 ^ 10) ^/ 10
writeln 64 ^/ 6
writeln()
 
val .nthroot = fn(.n, .A, .p) {
var .x = [.A, .A / .n]
while abs(.x[2]-.x[1]) > .p {
.x = [.x[2], ((.n-1) x* .x[2] + .A / (.x[2] ^ (.n-1))) / .n]
}
simplify .x[2]
}
 
Line 2,387 ⟶ 2,388:
 
writeln "function"
writeln .nthroot(10, 7131.5 ^ 10, 0.001)
writeln .nthroot(6, 64, 0.001)</syntaxhighlight>
</syntaxhighlight>
 
{{out}}
1,007

edits