-
Notifications
You must be signed in to change notification settings - Fork 0
/
psp_with_large_gpf.pl
55 lines (38 loc) · 1.12 KB
/
psp_with_large_gpf.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
49
50
51
52
53
54
55
#!/usr/bin/perl
use 5.020;
use autodie;
use warnings;
use Math::GMPz;
use Storable;
use ntheory qw(:all);
eval { require GDBM_File };
my $cache_db = "/home/swampyx/Other/Programare/experimental-projects/pseudoprimes/programs/cache/factors.db";
dbmopen(my %cache_db, $cache_db, 0444)
or die "Can't create/access database <<$cache_db>>: $!";
#while (my ($key, $value) = each %cache_db) {
while (<>) {
/\S/ || next;
chomp;
my $n = $_;
$n > ~0 or next;
my $value = $cache_db{$n};
if (not defined $value) {
warn "# $n does not exist in the DB!\n";
say $n;
next;
}
my @factors = split(' ', $value);
if (scalar(@factors) >= 3) {
if (Math::Prime::Util::GMP::sqrtint($factors[-1]) > $factors[-2]) {
my $v = Math::Prime::Util::GMP::vecprod(@factors[0..$#factors-1]);
if (exists $cache_db{$v}) {
#say "Ignoring: $n -> $v -- ", Math::Prime::Util::GMP::sqrtint($factors[-1]), " > ", $factors[-2];
#say $v;
say $n;
next;
}
}
}
#say $n;
}
dbmclose(%cache_db);