Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Prime Number Finder

by tall_man (Parson)
on Mar 07, 2005 at 23:00 UTC ( #437338=note: print w/ replies, xml ) Need Help??

in reply to Prime Number Finder

There's also Math::Pari which can do this sort of calculation extremely fast and with huge numbers:

use strict; use Math::Pari qw(:int PARI nextprime); print "Find primes from: "; chomp(my $o = <>); print "to: "; chomp(my $e = <>); $o = PARI $o; $e = PARI $e; if ($o > $e) { ($o,$e) = ($e,$o); } my $p = nextprime($o); while ($p <= $e) { print "$p is prime\n"; $p = nextprime($p + 1); }

Update: Fixed the code so that numbers not representable as integers can be converted to PARI objects.

Comment on Re: Prime Number Finder
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://437338]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (12)
As of 2015-11-30 18:06 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (778 votes), past polls