Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 13th, 2011  |  syntax: None  |  size: 0.49 KB  |  views: 44  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. sub is_prime {
  2.   my @x = (`factor $_[0]` =~ / /g);
  3.   return @x == 1;
  4. }
  5.  
  6. sub is_semiprime {
  7.   return 0 if int(sqrt($_[0])) ** 2 == $_[0];
  8.   my @x = (`factor $_[0]` =~ / /g);
  9.   return @x == 2;
  10. }
  11.  
  12. for my $n (12 .. 1000000) {
  13.   next if $n % 2;
  14.  
  15.   my $found = 0;
  16.   for my $p (3 .. $n) {
  17.     next unless $p % 2;
  18.     my $q = $n - $p;
  19.     next unless $q % 2;
  20.     next unless is_prime($p);
  21.     next unless is_semiprime($q);
  22.     $found = 1;
  23.     last;
  24.   }
  25.  
  26.   print "$n\n" unless $found;
  27. }
clone this paste RAW Paste Data