Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
11
Task/Nth-root/Sidef/nth-root-1.sidef
Normal file
11
Task/Nth-root/Sidef/nth-root-1.sidef
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
func nthroot(n, a, precision=1e-5) {
|
||||
var x = 1.float
|
||||
var prev = 0.float
|
||||
while ((prev-x).abs > precision) {
|
||||
prev = x;
|
||||
x = (((n-1)*prev + a/(prev**(n-1))) / n)
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
say nthroot(5, 34) # => 2.024397458501034082599817835297912829678314204
|
||||
6
Task/Nth-root/Sidef/nth-root-2.sidef
Normal file
6
Task/Nth-root/Sidef/nth-root-2.sidef
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
func nthroot_fast(n, a, precision=1e-5) {
|
||||
{ a = nthroot(2, a, precision) } * int(n-1)
|
||||
a ** (2**int(n-1) / n)
|
||||
}
|
||||
|
||||
say nthroot_fast(5, 34, 1e-64) # => 2.02439745849988504251081724554193741911462170107
|
||||
Loading…
Add table
Add a link
Reference in a new issue