Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.

Re: Prime Number Finder

by tall_man (Parson)
on Mar 07, 2005 at 23:00 UTC ( [id://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.

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2024-05-29 14:14 GMT
Find Nodes?
    Voting Booth?

    No recent polls found