On Sun, 2006-02-12 at 18:22 +0100, Michael Hanselmann wrote:
> Hello
> 
> For an ebuild I'm working on, I need a function to test wether a number
> is a prime number. For that, I wrote an Eclass you find attached to this
> e-mail. Can this be commited?
In what range do you need the random numbers?
Your implementation uses a naive test that runs in O(n), so any large
input will cause it to take excessively long:

time primes 100 1000
real    0m0.160s

time primes 10000 10100
real    0m7.309s

And I guess a 32-bit prime is out of reach :-)
-- 
Stand still, and let the rest of the universe move

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to