Ruud H.G. van Tol on Wed, 24 Jan 2024 17:02:59 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: log_int_rat



On 2024-01-24 15:39, Charles Greathouse wrote:
You can make it faster by storing only the exponent.

first(n)=my(a=-1,b=1,r=-1); vector(n, i, a+=2; b*=3; if(b>>a, , a++; b*=3; r++); 2*i+r)

On my system this is about twice as fast.

Hello Charles, thanks!

  first(2^17);

took 609ms here, and

  alist(2^17);

took 1013 ms.

-- Ruud