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]
$\endgroup$PrimePi
is much faster. $\endgroup$PrimePi
. $\endgroup$NextPrime[#, -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 :-) $\endgroup$Prime
has an extensible domain, however you can't extend it up torsa768a
unless you have an enormous amount of RAM, but it is unlikely realizable. $\endgroup$