-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.pl
48 lines (32 loc) · 834 Bytes
/
generate.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl
# Try to generate a base-2 pseudoprime from combinations of primes.
use 5.014;
use warnings;
use ntheory qw(:all);
use List::Util qw(shuffle);
my @primes;
while (<>) {
next if /%#/;
/\d/ or next;
chomp;
my $n = (split(' ', $_))[-1];
is_prime($n) || next;
modint($n, 8) == 3 or next;
kronecker(5, $n) == -1 or next;
push @primes, $n;
}
my $n = scalar(@primes);
say ":: Found $n primes...";
for(my $k = 3; $k <= $n; $k += 2) {
@primes = shuffle(@primes);
my $nok = binomial($n, $k);
say ":: Testing: $k -- tries: 10^", log("$nok")/log(10);
my $tries = 0;
forcomb {
my $psp = vecprod(@primes[@_]);
if ($psp > ~0 and is_pseudoprime($psp, 2)) {
say "Found: $psp";
}
lastfor if (++$tries > 1e6);
} $n, $k;
}