Prime[n] implemented in Mathematica? I have just observed that calculating large primes is quite fast (but not in
In:= Prime[10^11] Out= 2760727302517 //not instant In:= Prime[10^11] Out= 2760727302517 //instant In:= Prime[10^12] Out= 29996224275833 //not instant, seems to be k times longer than 10^11
I have also observed that it uses
~O(1) memory so things like Atkin sieve are not used there and that results are stored in memory because each next query returns result instantly.
In reference there are not details about that.
From the other hand it can't be predefined (it is not O(1)) but after putting:
In:= Prime[10^20] Prime::largp: Argument 100000000000000000000 in Prime is too large for this implementation. Out= Prime
Why is this bound if that implementation has not predefined primes?