login
Transpose of array A268833.
3

%I #11 Dec 07 2019 12:18:28

%S 0,1,0,2,1,0,1,2,1,0,2,3,2,1,0,3,2,3,2,1,0,2,1,2,1,2,1,0,1,2,3,2,3,2,

%T 1,0,2,3,4,3,2,1,2,1,0,3,2,3,4,3,2,1,2,1,0,4,3,2,3,4,3,2,3,2,1,0,3,4,

%U 1,2,3,4,3,2,3,2,1,0,2,3,2,3,2,3,2,1,2,1,2,1,0,3,2,3,2,3,2,1,2,3,2,1,2,1,0,2,1,2,1,4,3,2,3,4,3,2,3,2,1,0

%N Transpose of array A268833.

%C See comments in A268833.

%H Antti Karttunen, <a href="/A268834/b268834.txt">Table of n, a(n) for n = 0..8255; the first 128 antidiagonals of array</a>

%e The top left [0 .. 16] x [0 .. 16] section of the array:

%e 0, 1, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 3, 2, 1, 2

%e 0, 1, 2, 3, 2, 1, 2, 3, 2, 3, 4, 3, 2, 1, 2, 3, 2

%e 0, 1, 2, 3, 2, 3, 4, 3, 2, 1, 2, 3, 2, 3, 4, 3, 2

%e 0, 1, 2, 1, 2, 3, 4, 3, 2, 3, 2, 1, 2, 3, 4, 3, 2

%e 0, 1, 2, 3, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 3, 2

%e 0, 1, 2, 1, 2, 3, 4, 3, 2, 3, 4, 3, 4, 5, 4, 3, 2

%e 0, 1, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 4, 5, 4, 3, 2

%e 0, 1, 2, 3, 2, 1, 2, 3, 2, 3, 4, 5, 4, 3, 4, 3, 2

%e 0, 1, 2, 3, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 3, 2

%e 0, 1, 2, 1, 2, 3, 4, 3, 2, 3, 4, 3, 4, 5, 4, 3, 2

%e 0, 1, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 4, 5, 4, 3, 2

%e 0, 1, 2, 3, 2, 1, 2, 3, 2, 3, 4, 5, 4, 3, 4, 3, 2

%e 0, 1, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 3, 2, 1, 2

%e 0, 1, 2, 3, 2, 1, 2, 3, 2, 3, 4, 3, 2, 1, 2, 3, 2

%e 0, 1, 2, 3, 2, 3, 4, 3, 2, 1, 2, 3, 2, 3, 4, 3, 2

%e 0, 1, 2, 1, 2, 3, 4, 3, 2, 3, 2, 1, 2, 3, 4, 3, 2

%e 0, 1, 2, 3, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 3, 2

%t A101080[n_, k_]:= DigitCount[BitXor[n, k], 2, 1];A003188[n_]:=BitXor[n, Floor[n/2]]; A006068[n_]:=If[n<2, n, Block[{m=A006068[Floor[n/2]]}, 2m + Mod[Mod[n,2] + Mod[m, 2], 2]]]; a[r_, 0]:= 0; a[0, c_]:=c; a[r_, c_]:= A003188[1 + A006068[a[r - 1, c - 1]]]; A[r_, c_]:=A101080[c, a[r, r + c]]; Table[A[r - c, c], {r, 0, 20}, {c, 0, r}] // Flatten (* _Indranil Ghosh_, Apr 02 2017 *)

%o (Scheme)

%o (define (A268834 n) (A268833bi (A025581 n) (A002262 n))) ;; Code for A268833bi given in A268833.

%o (PARI) b(n) = if(n<1, 0, b(n\2) + n%2);

%o A101080(n, k) = b(bitxor(n, k));

%o A003188(n) = bitxor(n, n\2);

%o A006068(n) = if(n<2, n, {my(m = A006068(n\2)); 2*m + (n%2 + m%2)%2});

%o A268820(r, c) = if(r==0, c, if(c==0, 0, A003188(1 + A006068(A268820(r - 1, c - 1)))));

%o A(r, c) = A101080(c, A268820(r, r + c));

%o for(r=0, 20, for(c=0, r, print1(A(r - c, c),", ");); print();) \\ _Indranil Ghosh_, Apr 02 2017

%o (Python)

%o def A101080(n, k): return bin(n^k)[2:].count("1")

%o def A003188(n): return n^(n/2)

%o def A006068(n):

%o ....if n<2: return n

%o ....else:

%o ........m=A006068(n/2)

%o ........return 2*m + (n%2 + m%2)%2

%o def A268820(r, c): return c if r<1 else 0 if c<1 else A003188(1 + A006068(A268820(r - 1, c - 1)))

%o def a(r, c): return A101080(c, A268820(r, r + c))

%o for r in range(0, 21):

%o ....print [a(r - c, c) for c in range(0, r + 1)] # _Indranil Ghosh_, Apr 02 2017

%Y Transpose of A268833.

%K nonn,tabl

%O 0,4

%A _Antti Karttunen_, Feb 15 2016