10-12-2006, 04:56 PM
Make a program that calculates the value of the 1,000th, the 10,000th and the 100,000th prime. If FB is used the 1,000,000th prime must be calculated too.
The first prime is 2, the second is 3 and so on...
The number of primes up to the integer x can be aproximated by x/(log(x)-1) (QB's log)
The winner is who has the three primes right and faster.
References:
All you wanted to know about primes and never dared to ask http://primes.utm.edu/
The idea is to generate primes and count them up to the required count. There are a lot of optimizations possible in this generation and counting so I hope we will get some interesing sources.
We can open 3 categories according to the speed and memory limitations: Qbasic, Qb4.5 and FreeBASIC
EDITED: Added an additional request for FB, without it even an unoptimized souce takes less than 0.5 second.
EDIT2: For reference, the results are
of course your program must FIND these results!
The first prime is 2, the second is 3 and so on...
The number of primes up to the integer x can be aproximated by x/(log(x)-1) (QB's log)
The winner is who has the three primes right and faster.
References:
All you wanted to know about primes and never dared to ask http://primes.utm.edu/
The idea is to generate primes and count them up to the required count. There are a lot of optimizations possible in this generation and counting so I hope we will get some interesing sources.
We can open 3 categories according to the speed and memory limitations: Qbasic, Qb4.5 and FreeBASIC
EDITED: Added an additional request for FB, without it even an unoptimized souce takes less than 0.5 second.
EDIT2: For reference, the results are
Code:
the 1000 th prime is 7919
the 10000 th prime is 104729
the 100000 th prime is 1299709
the 1000000 th prime is 15485863