Ruud H.G. van Tol on Tue, 17 Oct 2023 19:32:09 +0200


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

Re: digits(n,-4)



On 2023-10-17 17:58, Ruud H.G. van Tol wrote:
On 2023-10-15 12:46, Ruud H.G. van Tol wrote:
[...]

Still playing:

Yet Another Path:

? [ negdigits(n,-2) |n<-[0..10] ]
% [[], [1], [1, 1, 0], [1, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0, 1, 0], [1, 1, 0, 1, 1], [1, 1, 0, 0, 0], [1, 1, 0, 0, 1], [1, 1, 1, 1, 0]]


negbinary(n)= { my(t=(32*4^logint(abs(n)+1,4)-2)/3); digits(bitxor(n+t,t),2); }

? [ negbinary(n) |n<-[0..10] ]
% [[], [1], [1, 1, 0], [1, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0, 1, 0], [1, 1, 0, 1, 1], [1, 1, 0, 0, 0], [1, 1, 0, 0, 1], [1, 1, 1, 1, 0]]


-- Ruud