robert44444uk,

No problem. I had another crack at it using what I thought would entail slightly less overhead:

#!/usr/bin/perl -slw use strict; use Math::GMPz qw(:mpz); my @crt = qw( 68083089690 131417981310 36415643880 51194848320 106157886450 30083217780 154569039240 55922110860 18269362650 12688113900 108608348310 2163950250 195808561410 89629478400 35610139950 164950347870 104015130450 198396537570 4751926410 91952139510 187872373920 182291125170 144638376960 149365639500 45991448580 94402601370 142813754160 69142506510 132477398130 164144843940 ); my $beg = shift || 91960283; my $end = shift || 300000000; my $fact = 2*3*5*7*11*13*17*19*23*29*31; my $target = 650; open FH, '>', 'prime_dump.txt' or die "could not open file: $!\n"; for my $i ($beg .. $end) { for (@crt) { my $num = $fact*$i+$_; my $start = Rmpz_init(); my_prev_prime_p($start,$num); my $end = Rmpz_init(); Rmpz_nextprime($end, Math::GMPz->new( +$num)); my $gap = Rmpz_init(); Rmpz_sub($gap, $end, $start); print FH "$i $_ $gap ",$gap/log($num) if $gap > $target; } } close FH; # ---------------------------------------------------------------- # Find probable prime that precedes param2 via Rmpz_probab_prime_p # ---------------------------------------------------------------- sub my_prev_prime_p { my ($rop,$num) = (shift,shift); my $i = $num; Rmpz_set_d($rop,2); # default param1 to 2 (the smallest prime) while ($i > 2) { $i--; next unless $i % 2; # evaluate odd numbers only Rmpz_set_str($rop,$i,10) || return if Rmpz_probab_prime_p(Math +::GMPz->new($i),10); } return; } __END__

However, it performed just as bad as your attempts using next_prime and prev_prime if not worse...

We'd be very keen to see how/if you managed to get your script to perform better.

Best of luck (and God speed)
shadowsong


In reply to Re^3: Odd error message by shadowsong
in thread Odd error message by robert44444uk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.