Is there a a function for calculating nth prime number? A near approximate answer would also do as I need for numbers below 1000.
-
2There are only 168 primes below 1000, so a lookup table might be best and simplest – Hagen von Eitzen Oct 26 '18 at 10:56
-
Being curious, still if i need bigger numbers – Atharva Kathale Oct 26 '18 at 10:58
1 Answers
Get $1^{st}$ 1000 primes here
From wiki:
There is no known efficient formula to calculate $n^{th}$ prime number.
For example, there is no non-constant polynomial, even in several variables, that takes only prime values.
However, there are numerous expressions that do encode all primes, or only primes.
One possible formula is based on Wilson's theorem and generates the number 2 many times and all other primes exactly once.
There is also a set of Diophantine equations in nine variables and one parameter with the following property:
The parameter is prime if and only if the resulting system of equations has a solution over the natural numbers. This can be used to obtain a single formula with the property that all its positive values are prime.
- 2,575