Thread: Prime Gap News
View Single Post
Old 2020-11-28, 13:48   #201
robert44444uk's Avatar
Jun 2003
Oxford, UK

1,933 Posts

For very large gaps I used the sieve_primes routine and then pfgw. Here is a ready to use perl program - clearly change your variables. It produces a pfgw-ready file.

#!/usr/bin/env perl

# takes a specific A - the best of a range of A already tested for candidates of type A*p#/46410 and sieves deep. 1tn takes about 14 hours. 50m takes 70 minutes.

use warnings;
use strict;
use Math::BigFloat lib=>"GMP";
use Math::Prime::Util qw/:all/;
use Math::GMPz;
use feature ':5.10';
use File::Slurp;
use ntheory ":all";
$| = 1;

my $mult = 1787;
my $prim = 80021;
my $range = 1_021_020;
my $sievelim = 1_000_000_000_000; 
my $div = 46410;

my $fact = Math::GMPz->new("".primorial($prim));
my $filetitle = "ABC"." ".$mult."*".$prim."#"."/".$div."+".q[$a];

my $n = $mult*$fact/$div; 
my @f = Math::Prime::Util::GMP::sieve_primes($n-($range/2), $n+($range/2), $sievelim); 

foreach my $item (@f) {
    $item = $item-$n;

#say scalar(@f);
#print "@f\n";

my $filename = '1787to1tn.txt';
open(my $fh, '>', $filename) or die "Could not open file '$filename' $!";
print $fh "$filetitle\n";
print $fh join "\n", @f;
close $fh;
print "done\n";
robert44444uk is offline   Reply With Quote