Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- @abcheck;
- for $i (1..28123) {
- my @div1;
- my $d1;
- my $sum1 = 0;
- my $n1 = ($i/2);
- for $j (1..$n1) {
- push(@div1,$j) if ($i % $j == 0);
- }
- for $d1 (@div1) {
- $sum1 += $d1;
- }
- # print "Divisors of $i are @div1, which add to $sum1\n";
- if ($sum1 < $i) {
- # print "$i is a deficient number\n";
- } elsif ($sum1 == $i) {
- # print "$i is a perfect number\n";
- } else {
- # print "$i is an abundant number\n";
- $abcheck[$i] = 1;
- }
- }
- $total = 0;
- for $i (1..28123) {
- my $is = 0;
- for $j (1..$i) {
- if ($abcheck[$j] && $abcheck[($i - $j)]) {
- $is = 1;
- last;
- }
- }
- $total += $i if !$is;
- print "Checked $i numbers, running total is $total\n" if ($i % 1000 == 0);
- }
- print "Sum of integers !(ab+ab): $total\n";
Add Comment
Please, Sign In to add comment