187 Semiprimes -- v2.pl 346 B

1234567891011121314151617181920212223
  1. #!/usr/bin/perl
  2. # Derived from a method posted by Dana Jacobsen.
  3. # Date: 22 August 2016
  4. # https://projecteuler.net/problem=187
  5. # Runtime: 0.051s
  6. use strict;
  7. use integer;
  8. use ntheory qw(prime_count forprimes);
  9. my $limit = 10**8-1;
  10. my $count = 0;
  11. forprimes {
  12. $count += prime_count($_, $limit/$_);
  13. } int(sqrt($limit));
  14. print "$count\n";