George Szpiro wrote:
>My last posting did not have the program listing:
>
>
>can somebody explain why Prime[...] slows down so drastically and so
>abruptly at about 105
>million (see below)?
>
>also: how can I get elapsed time in fractions of seconds? (Timing[...] did
>not work inside the loop for some reason.)AboluteTime to give
>
>Thanks,
>
>George
>george at netvision.net.il
>
>
>Sets=100;
>
>KK=20000;
>
>InitValue=105000000;
>
>Steps=10000;
>
>For[k=1,k<=Sets,k++,
>
> TT=AbsoluteTime[];
>
> For[j=1,j<=KK,j++, x=2*Prime[InitValue+k*Steps+j];]
>
> Print["Prime[",InitValue+k*Steps+j-1,"]=",Prime[InitValue+k*Steps+j-1],"
>Time ",AbsoluteTime[]-TT];
>
> TT=AbsoluteTime[];]
>
>Prime[105010000]=2145604099 Time 1.00000
>
>Prime[105030000]=2146031753 Time 2.00000
>
>
The jump is explained by the computation below.
In[4]:= PrimePi[2^31]-1
Out[4]= 105097564
So between 105090000 and 105100000 we move from machine integers to
bignums. Performing arithmetic on these is slower.
Daniel Lichtblau
Wolfram Research