Guest User

Untitled

a guest
Sep 14th, 2011
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. sub is_prime {
  2. my $n = shift;
  3. return 0 if $n < 2 || $n % 2 == 0;
  4. my $sn = int(sqrt($n));
  5. for (my $j = 3; $j <= $sn; $j += 2) {
  6. return 0 if $n % $j == 0;
  7. }
  8. return 1;
  9. }
  10.  
  11. for my $ln (4 .. 1000000) {
  12. next unless $ln % 2;
  13. my $n = (1 << $ln);
  14.  
  15. for my $p (3 .. $n) {
  16. next unless $p % 2;
  17. my $q = $n - $p;
  18. next unless $q % 2;
  19. next unless is_prime($p);
  20. next unless is_prime($q);
  21. next unless is_prime(($p - 1) / 2) || is_prime(($q - 1) / 2);
  22. die "$n has a prime+safeprime representation";
  23. }
  24.  
  25. print "$n\n";
  26. }
Advertisement
Add Comment
Please, Sign In to add comment