Posted By

cmm7825 on 06/25/10


Tagged


Versions (?)

Problem 34


 / Published in: Perl
 

  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. my $i = 10;
  7. my $total = 0;
  8. while($i <= 40585){
  9. my $sum = 0;
  10. my @digits = ($i =~ m/(\d)/g);
  11. foreach my $digit (@digits){
  12. my $temp = 1;
  13. my @fact = (2..$digit);
  14. map $temp *= $_ ,@fact;
  15. $sum += $temp
  16. }
  17. $total += $i if ($sum == $i);
  18. $i++;
  19. }
  20.  
  21. print "$total\n";

Report this snippet  

You need to login to post a comment.