Advertisement

Primes

Started by May 20, 2003 10:03 AM
60 comments, last by walkingcarcass 21 years, 7 months ago
Does anyone have a list of primes in the range [2, 2^32-1] ? How big is this list? ******** A Problem Worthy of Attack Proves It''s Worth by Fighting Back
spraff.net: don't laugh, I'm still just starting...
I don''t have a list, but it should be fairly trivial to write a program that''ll build one.

<img src=http://webspace.utexas.edu/~mvdepala/random/resist-ignorance.png
Advertisement
Yeah, it should be quite easy to build a list, although I''m sure you can find one somewhere.
well... up to 2^20 there are about 82000 primes...
That porgram will have to run for a looong time...


____________________ ____ ___ __ _
Enselic''s Corner - My site. Go test my game Spatra and see if you can beat it onto the Official Spatra Top 10.
CodeSampler.com - Great site with source for specific tasks in DirectX and OpenGL.
[s]--------------------------------------------------------[/s]chromecode.com - software with source code
From A comprehensive introduction to prime numbers: (slightly edited)

"Let N(n) be the number of primes less than n. In 1792, Karl Gauss conjectured that N(n) approaches n/(ln n) as n becomes larger and larger." (This was later proved to be true.)

N(2^20) is about 76,000 (reasonably close to the 82,000 mentioned by AP)

N(2^32) is about 194,000,000, so of the order of 740Mb to store them all? Maybe you could compress them onto a CD

Miles
Advertisement
quote:
Original post by Enselic
That porgram will have to run for a looong time...

Yes, about 15 minutes. The number of primes appears to be 203280221.
quote:
Original post by Enselic
That porgram will have to run for a looong time...

I think on modern computers, it would only have to run for a matter of minutes. Not exactly a long time per se...


<img src=http://webspace.utexas.edu/~mvdepala/random/resist-ignorance.png
A table that contained all the primes from 1 to 2^32 (minus one doesn''t matter because 2^32 is an even number) would be very long. The symbol for the number of primes less than a number x > 0 is given by the pi function, pi (x).

Like Miles Clapham said, pi (x) log (x) / x approach 1 as x approaches infinity. (i.e., pi (x) ~ x / log x.) A much better approximation is given by the integral (like my integral ? )
x
§ (1 / log t) dt
2
I believe this is also due to Gauss.

I used simpsons rule with a division of 2^21 and got 203284494 which agrees closely with AP. Use the integral instead of
x / log x,
it is more acuarate.

no wise fish would go anywhere without a porpoise - The Mock Turtle
Ask an autistic child for the primes, he/she will give them to you.

This topic is closed to new replies.

Advertisement