Gentoo Archives: gentoo-dev

From: Patrick Lauer <patrick@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Eclass for prime numbers
Date: Sun, 12 Feb 2006 17:46:58
Message-Id: 1139766121.18205.26.camel@localhost
In Reply to: [gentoo-dev] Eclass for prime numbers by Michael Hanselmann
1 On Sun, 2006-02-12 at 18:22 +0100, Michael Hanselmann wrote:
2 > Hello
3 >
4 > For an ebuild I'm working on, I need a function to test wether a number
5 > is a prime number. For that, I wrote an Eclass you find attached to this
6 > e-mail. Can this be commited?
7 In what range do you need the random numbers?
8 Your implementation uses a naive test that runs in O(n), so any large
9 input will cause it to take excessively long:
10
11 time primes 100 1000
12 real 0m0.160s
13
14 time primes 10000 10100
15 real 0m7.309s
16
17 And I guess a 32-bit prime is out of reach :-)
18 --
19 Stand still, and let the rest of the universe move

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-dev] Eclass for prime numbers Michael Hanselmann <hansmi@g.o>