Consider p such that PrimeQ[p] == True. How do I compute n such that Prime[n] == p?
In other words, what is the inverse function of "Prime"?
EDIT:
As a concrete example, consider p to be the first prime that factorizes rsa-768,
p = rsa768a = 33478071698956898786044169848212690817704794983713768568912431388982883793878002287614711652531743087737814467999489
PrimeQ[rsa768a] is True; I want to know its n.
Trying Jason's suggestion, InverseFunction[Prime][rsa768a], does not return the expected result (for a small prime it does). Trying LLlAMnYP suggestion, PrimePi[rsa768a] returns
PrimePi::largp: Argument ... in PrimePi[...] is too large for this implementation. >>
InverseFunction[Prime]– Jason B. Mar 09 '16 at 09:21PrimePiis much faster. – LLlAMnYP Mar 09 '16 at 09:24PrimePi. – LLlAMnYP Mar 09 '16 at 09:28PrimePiwill take non-prime numbers and give an answer – Jason B. Mar 09 '16 at 09:28primePi[x_?PrimeQ]:=PrimePi[x]– LLlAMnYP Mar 09 '16 at 09:30NextPrime[#, -1]&but good luck waiting for that computation to end in this universe. There's a reason, that these things are used for encryption, y'know :-) – LLlAMnYP Mar 09 '16 at 09:36Primehas an extensible domain, however you can't extend it up torsa768aunless you have an enormous amount of RAM, but it is unlikely realizable. – Artes Mar 09 '16 at 09:52n Log[n] == p(or other approximation of $p_n$) for n. – Jorge Leitao Mar 09 '16 at 10:15PrimePisee e.g. Approximation to the prime counting function. – Artes Mar 09 '16 at 10:22nin any sensible time for such large primes (well, maybe doing some original research in quantum computation might help), but maybe you can live with the factRiemannRis good for an approximation. – kirma Mar 09 '16 at 11:38