Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
14
Task/Nth-root/Perl/nth-root-1.pl
Normal file
14
Task/Nth-root/Perl/nth-root-1.pl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
use strict;
|
||||
|
||||
sub nthroot ($$)
|
||||
{
|
||||
my ( $n, $A ) = @_;
|
||||
|
||||
my $x0 = $A / $n;
|
||||
my $m = $n - 1.0;
|
||||
while(1) {
|
||||
my $x1 = ($m * $x0 + $A / ($x0 ** $m)) / $n;
|
||||
return $x1 if abs($x1 - $x0) < abs($x0 * 1e-9);
|
||||
$x0 = $x1;
|
||||
}
|
||||
}
|
||||
3
Task/Nth-root/Perl/nth-root-2.pl
Normal file
3
Task/Nth-root/Perl/nth-root-2.pl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
print nthroot(5, 34), "\n";
|
||||
print nthroot(10, 7131.5 ** 10), "\n";
|
||||
print nthroot(0.5, 7), "\n";
|
||||
Loading…
Add table
Add a link
Reference in a new issue