Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Nth-root/E/nth-root.e
Normal file
12
Task/Nth-root/E/nth-root.e
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
def nthroot(n, x) {
|
||||
require(n > 1 && x > 0)
|
||||
def np := n - 1
|
||||
def iter(g) { return (np*g + x/g**np) / n }
|
||||
var g1 := x
|
||||
var g2 := iter(g1)
|
||||
while (!(g1 <=> g2)) {
|
||||
g1 := iter(g1)
|
||||
g2 := iter(iter(g2))
|
||||
}
|
||||
return g1
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue