Bill Allombert on Sun, 11 Jan 2026 18:18:43 +0100


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

Re: fibint(n), fibbinary(n)


On Sun, Jan 11, 2026 at 05:45:42PM +0100, Ruud H.G. van Tol wrote:
> 
> I'm looking for an effective (discrete, loop-less) way to derive the n-th
> fibbinary number (Zeckendorf representation).
> For definitions, see https://oeis.org/A003714.
> 
> [ n | n<-[0..100], !bitand(n,n>>1) ]
> [0,
> 1,
> 2,
> 4, 5,
> 8, 9, 10,
> 16, 17, 18, 20, 21,
> 32, 33, 34, 36, 37, 40, 41, 42,
> 64, 65, 66, 68, 69, 72, 73, 74, 80, 81, 82, 84, 85
> ]
> 
> - - - - - -
> 
> While on that path, I'm currently also looking for a discrete implementation
> of "fibint", and rather without loop.
> I think that fibint(n) should return the index of the fibonacci number <= n.

fibintexa(n)=round(log(sqrt(5)*n)/log((1+sqrt(5))/2))
fibint(n)=my(m=fibintexa(n),f=fibonacci(m));if(f>n,f-1,f);

Cheers,
Bill.