Add all the A tasks
This commit is contained in:
parent
2dd7375f96
commit
051504d65b
1608 changed files with 18584 additions and 0 deletions
13
Task/Arithmetic-Rational/Perl/arithmetic-rational.pl
Normal file
13
Task/Arithmetic-Rational/Perl/arithmetic-rational.pl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
use bigrat;
|
||||
|
||||
foreach my $candidate (2 .. 2**19) {
|
||||
my $sum = 1 / $candidate;
|
||||
foreach my $factor (2 .. sqrt($candidate)+1) {
|
||||
if ($candidate % $factor == 0) {
|
||||
$sum += 1 / $factor + 1 / ($candidate / $factor);
|
||||
}
|
||||
}
|
||||
if ($sum->denominator() == 1) {
|
||||
print "Sum of recipr. factors of $candidate = $sum exactly ", ($sum == 1 ? "perfect!" : ""), "\n";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue