Advertisement
Guest User

Untitled

a guest
Sep 13th, 2011
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement