Posted By

cmm7825 on 05/20/10


Tagged


Versions (?)

Problem 12


 / Published in: Perl
 

  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use POSIX qw(floor);
  5.  
  6. my $n = 0;
  7. my $count = 0;
  8. my $i = 1;
  9.  
  10. while($count<500){
  11. $count = 2;
  12. $n += $i;
  13. $i++;
  14. foreach (2..floor($n**0.5)){
  15. $count+=2 if $n % $_ == 0;
  16. }
  17. }
  18.  
  19. print $n;

Report this snippet  

You need to login to post a comment.