tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 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