# A prime returning function?

• Jun 9th 2010, 07:38 AM
mfetch22
A prime returning function?
Is there such a fuction of the form \$\displaystyle P(n)\$ which returns the \$\displaystyle nth\$ prime number? The function would be such that:

\$\displaystyle P(1) = 2\$
\$\displaystyle P(2) = 3\$
\$\displaystyle P(3) = 5\$
\$\displaystyle P(4) = 7\$
\$\displaystyle P(5) = 11\$
.
.
.
.

I think the idea is clear. Is there such a function? Or reasearch on such a function?
• Jun 9th 2010, 07:48 AM
undefined
Quote:

Originally Posted by mfetch22
Is there such a fuction of the form \$\displaystyle P(n)\$ which returns the \$\displaystyle nth\$ prime number? The function would be such that:

\$\displaystyle P(1) = 2\$
\$\displaystyle P(2) = 3\$
\$\displaystyle P(3) = 5\$
\$\displaystyle P(4) = 7\$
\$\displaystyle P(5) = 11\$
.
.
.
.

I think the idea is clear. Is there such a function? Or reasearch on such a function?

If you don't need to go very high, you could write a sieve. Here's a website that allows you to find the nth prime for n up to \$\displaystyle 10^{12}\$.
• Jun 9th 2010, 08:13 AM
chiph588@
Quote:

Originally Posted by mfetch22
Is there such a fuction of the form \$\displaystyle P(n)\$ which returns the \$\displaystyle nth\$ prime number? The function would be such that:

\$\displaystyle P(1) = 2\$
\$\displaystyle P(2) = 3\$
\$\displaystyle P(3) = 5\$
\$\displaystyle P(4) = 7\$
\$\displaystyle P(5) = 11\$
.
.
.
.

I think the idea is clear. Is there such a function? Or reasearch on such a function?

Formula for primes - Wikipedia, the free encyclopedia

This is as close as you can get to a true prime number formula.
• Jun 9th 2010, 08:22 AM
undefined
Quote:

Originally Posted by chiph588@
Formula for primes - Wikipedia, the free encyclopedia

This is as close as you can get to a true prime number formula.

That polynomial inequality in 26 variables is trippy! Thanks for the link.
• Jun 9th 2010, 08:23 AM
Bruno J.
Of much interest is also Riemann's "explicit formula"!