Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Prime[..] slows down

  • To: mathgroup at
  • Subject: [mg53562] Re: [mg53524] Prime[..] slows down
  • From: Daniel Lichtblau <danl at>
  • Date: Tue, 18 Jan 2005 05:08:02 -0500 (EST)
  • References: <>
  • Sender: owner-wri-mathgroup at

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
>george at
>  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

  • Prev by Date: Re: NIntegrate with Minimize
  • Next by Date: Re: GUIKit: <<file quirk
  • Previous by thread: Re: Prime[..] slows down
  • Next by thread: LegendreP -- up to which order?