Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub is_prime {
- my $n = shift;
- return 0 if $n < 2 || $n % 2 == 0;
- my $sn = int(sqrt($n));
- for (my $j = 3; $j <= $sn; $j += 2) {
- return 0 if $n % $j == 0;
- }
- return 1;
- }
- for my $ln (4 .. 1000000) {
- next unless $ln % 2;
- my $n = (1 << $ln);
- for my $p (3 .. $n) {
- next unless $p % 2;
- my $q = $n - $p;
- next unless $q % 2;
- next unless is_prime($p);
- next unless is_prime($q);
- next unless is_prime(($p - 1) / 2) || is_prime(($q - 1) / 2);
- die "$n has a prime+safeprime representation";
- }
- print "$n\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment