/ Published in: Perl
Expand |
Embed | Plain Text
#!/usr/bin/perl use strict; use warnings; my $sum = 1; my %hash; foreach my $n (1..10000){ $sum = 1; foreach (2..floor($n**0.5)){ if($n % $_ == 0){ $sum += $_; $sum += $n/$_; } } $hash{$n} = $sum; } my $total = 0; my $value2 = 0; my $value1 = $hash{$key}; if($value1<10000){ $value2 = $hash{$value1};} if($key == $value2 && $value1 != $value2){ $total += $key;} } print "$total\n";
You need to login to post a comment.
