Prime challenge
Posted: Thu Nov 13, 2008 11:09 am
this challenge is basic and im sure everyone can part take.
challenge is to write a program that prints out consecutive primes up to prime closest to 100000.
winner is who ever program does it in the least time. any language is fair game. note however that you must use the program to tell you what your execution time was.
NB:: prime is a number that is only divisible by one and it self. (so that there is no remainder)
NOTE: 1 is not considered to be prime.
2,3,5,7,11,13....
here is one performance hint i can give you. you only have to test from 2 to floor(sqrt(X)) to see if X is prime. // that saves alot of time.
example: if we are testing if X = 53 is prime, sqrt(53) = 7.2801 floor(7.2801..) = 7.
so we only need to test 53%2 trough 53%7, if none of those are 0, then 53 is prime, which incidentally it is.
also if you really wanna go deep, look into sieve of aikin or somthing to that effect.
this is one of my favorite challenges because you can always make your program better. btw, if you can develope a really good prime algoritm you will never have to work in your like again.
Prime numbers are a big part of cryptography and thus people are willing to pay millions upon millions for prime number technology.
challenge is to write a program that prints out consecutive primes up to prime closest to 100000.
winner is who ever program does it in the least time. any language is fair game. note however that you must use the program to tell you what your execution time was.
NB:: prime is a number that is only divisible by one and it self. (so that there is no remainder)
NOTE: 1 is not considered to be prime.
2,3,5,7,11,13....
here is one performance hint i can give you. you only have to test from 2 to floor(sqrt(X)) to see if X is prime. // that saves alot of time.
example: if we are testing if X = 53 is prime, sqrt(53) = 7.2801 floor(7.2801..) = 7.
so we only need to test 53%2 trough 53%7, if none of those are 0, then 53 is prime, which incidentally it is.
also if you really wanna go deep, look into sieve of aikin or somthing to that effect.
this is one of my favorite challenges because you can always make your program better. btw, if you can develope a really good prime algoritm you will never have to work in your like again.
Prime numbers are a big part of cryptography and thus people are willing to pay millions upon millions for prime number technology.