Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 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;
|
||||
var prev = 0;
|
||||
while ((prev-x).abs > precision) {
|
||||
prev = x;
|
||||
x = (((n-1)*prev + a/(prev**(n-1))) / n);
|
||||
};
|
||||
return x;
|
||||
}
|
||||
|
||||
say nthroot(5, 34); # => 2.024397458501034082599817835297912829678
|
||||
Loading…
Add table
Add a link
Reference in a new issue