: : What is the most optimum method of finding a prime number?
: : Till we use a method of incrimenting a number and then dividing it with all the preceding numbers.
: : Kindly tell the most efficient method of finidng a prime number.
: : Post the code or link to it.]
: : Regards
: : chandan
: You can at least skip every second number since it is even and not prime. If you manage to deduce a formula of which the result is always a prime number, a math institute apparently will pay you one million dollars. I cant remember their name now.
This is one of the unsolved problems of mathematics.
One way to speed up the algorithm is to do like this:
until b = a OR (a mod b) > 0
if b = a, it's a prime
else it's not
Or even faster in assembler:
print "It's prime" ;OK, I don't got the time to write all the memmory.
print "It's not prime"
I wrote it in psuedo asm, I don't got time right now to write it in real asm.
Niklas Ulvinge aka IDK