Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
11
Task/Nth-root/Raku/nth-root.raku
Normal file
11
Task/Nth-root/Raku/nth-root.raku
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
sub nth-root ($n, $A, $p=1e-9)
|
||||
{
|
||||
my $x0 = $A / $n;
|
||||
loop {
|
||||
my $x1 = (($n-1) * $x0 + $A / ($x0 ** ($n-1))) / $n;
|
||||
return $x1 if abs($x1-$x0) < abs($x0 * $p);
|
||||
$x0 = $x1;
|
||||
}
|
||||
}
|
||||
|
||||
say nth-root(3,8);
|
||||
Loading…
Add table
Add a link
Reference in a new issue