Integer roots: Difference between revisions
→{{header|Perl 6}}: Improved endpoint to match actual solution condition, instead of just convergence.
(→{{header|Perl 6}}: Changed … to ... , for users of IDEOne.) |
(→{{header|Perl 6}}: Improved endpoint to match actual solution condition, instead of just convergence.) |
||
Line 144:
my $iterator = { ( $d * $^x + $n div ($^x ** $d) ) div $p };
my $endpoint = { $^x
and ($^x + 1) ** $p > $n };
return [min] (+$guess, $iterator ... $endpoint)[*-1, *-2];
|