epkid08 said:
I was under the impression that there existed no type of function or expression that took the form of P_n=f(N_p). I originally assumed this because 1) I've been told numerous times that there wasn't (probably told that there was no function)
The statement "There is no function that maps a positive integer n to the nth prime" is wrong. The statement "There is no closed-form expression that maps a positive integer n to the nth prime" is wrong, assuming closed-form expressions can use addition, subtraction, multiplication, division, exponents, factorials, indexed sums, and the floor function.
I'm not being condescending at all with the following statement:
Anyone who says that there is no formula for the primes doesn't know what they're talking about. There is no sensible interpretation under which that is true.
epkid08 said:
everybody makes a huge deal about the distribution of primes and finding an easy way to find all of the primes, and so I thought there existed no expression.
Yes, the formula I posted takes something like 2 * 4
n factorial calculations, which takes a
really long time for n greater than, say, 50. But calculating the difference between the 101st prime and the 100th prime, 547 - 541 = 6, is very easy. So improving on this closed-form expression with efficient algorithms is important.
epkid08 said:
Here's a final question, why, if we already have an expression in the form, P_n=f(N_p), are people still searching for high prime numbers?
Using the formula from post #13 to calculate that p_10 = 29 would take 1024 steps through the main loop. Each pass through the main loop runs the inner loop up to 1023 times. Each pass through the inner loop requires the calculation of two factorials, which may be as large as 1023! > 10
2336. In total, over a million factorials are computed, most of which are huge.
But you can instead check each number from 1 to 30 for divisibility by 2, 3, and 5 to determine that 29 is the 10th prime.
This method, millions of times faster than the formula from post #13, is called "trial division" and is considered too slow to test the primality of any but the smallest numbers.
epkid08 said:
Isn't this expression good enough to find any/all of the primes?
Given enough time that expression will (presumably) find any prime desired. But using a dual-core 1 THz computer, finding the 100th prime with that method would take longer than the life of the universe.