Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
A different take on finding primes
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dave Angel  
View profile  
 More options Nov 15, 1:22 am
Newsgroups: comp.lang.python
From: Dave Angel <da...@ieee.org>
Date: Sun, 15 Nov 2009 01:22:14 -0500
Local: Sun, Nov 15 2009 1:22 am
Subject: Re: A different take on finding primes

The sieve can be very efficiently written, but you have to decide
whether to optimize for memory size or for speed.  At a minimum for size
you need an object for each prime currently found, and you will be
looking through that list for each new candidate.  Incidentally this
approach can be done without any division.  If you have memory to burn,
you make a bit array equal in size to the largest prime you expect to
encounter.

There are also good algorithms for deciding whether a number of a
particular form is prime.  For example, there's a test for numbers of
the form 2**n + 1.

And don't forget the Miller-Rabin test.

DaveA


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tobiah  
View profile  
 More options Nov 16, 1:21 pm
Newsgroups: comp.lang.python
From: Tobiah <t...@rcsreg.com>
Date: Mon, 16 Nov 2009 18:21:08 GMT
Local: Mon, Nov 16 2009 1:21 pm
Subject: Re: A different take on finding primes

>> Let me
>> be clear, given 2min, how many primes can you find, they need not be in
>> order or consecutive.

Do they have to go from low to high?   :( )

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nigel Rowe  
View profile  
 More options Nov 17, 8:33 pm
Newsgroups: comp.lang.python
From: Nigel Rowe <s...@signature.invalid>
Date: Wed, 18 Nov 2009 12:33:24 +1100
Local: Tues, Nov 17 2009 8:33 pm
Subject: Re: A different take on finding primes
On Tue, 17 Nov 2009 05:21, Tobiah wrote in comp.lang.python
<<oKgMm.17283$ET3.3...@newsfe17.iad>>:

>>> Let me
>>> be clear, given 2min, how many primes can you find, they need not be
in
>>> order or consecutive.

> Do they have to go from low to high?   :( )

1) google list of prime numbers
2) see "Prime numbers list" in the results (number 3 in the results)
3) click link that leads to www.prime-numbers.org

I found 455042511 prime numbers in approx 15 seconds.

Is that what you wanted?

--
        Nigel Rowe
        A pox upon the spammers that make me write my address like..
                rho (snail) fisheggs (stop) name


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Anh Hai Trinh  
View profile  
 More options Nov 18, 4:55 am
Newsgroups: comp.lang.python
From: Anh Hai Trinh <anh.hai.tr...@gmail.com>
Date: Wed, 18 Nov 2009 01:55:24 -0800 (PST)
Local: Wed, Nov 18 2009 4:55 am
Subject: Re: A different take on finding primes

> 1) google list of prime numbers
> 2) see "Prime numbers list" in the results (number 3 in the results)
> 3) click link that leads towww.prime-numbers.org

> I found 455042511 prime numbers in approx 15 seconds.

Not bad at all. How about using http://www.sagemath.org/ (written in
Python).

    sage: time primes_first_n(10^7);
    CPU times: user 4.36 s, sys: 2.43 s, total: 6.79 s
    Wall time: 6.88 s

That used 3G of RAM, you could certainly go higher if you have more
memory.

----aht


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google