Anonymous user
Arithmetic/Rational: Difference between revisions
→{{header|Perl}}
(+Icon+Unicon) |
|||
Line 944:
[insert implementation here]
=={{header|Perl 6}}==
Perl 6 supports rational arithmetic natively.
<lang perl6>for 2..2**19 -> $candidate {
my $sum = 1 / $candidate;
for 2 .. ceiling(sqrt($candidate)) -> $factor {
if $candidate %% $factor {
$sum += 1 / $factor + 1 / ($candidate / $factor);
}
}
if $sum.denominator == 1 {
say "Sum of reciprocal factors of $candidate = $sum exactly", ($sum == 1 ?? ", perfect!" !! ".");
}
}
</lang>
=={{header|PicoLisp}}==
|