%I #10 Aug 01 2023 06:55:14
%S 0,0,1,1,0,1,0,1,1,2,1,1,2,0,1,1,2,0,1,1,2,2,0,1,1,2,1,2,0,1,1,2,1,2,
%T 2,3,1,1,2,1,2,2,3,0,1,1,2,1,2,2,3,0,1,1,2,2,1,2,2,3,0,1,1,2,1,2,1,2,
%U 2,3,0,1,1,2,1,2,2,3,2,2,3,0,1,1,2,1
%N Triangle read by rows: T(0,0) = 0; T(n+1,k) = T(n,k+1), 0 <= k < n; T(n+1,n) = T(n,0); T(n+1,n+1) = T(n,0)+1.
%C Let h be the initial term of row n, to get row n+1, remove h and then append h and h+1;
%C For n > 0: T(n,A035327(n)) = 0.
%H Reinhard Zumkeller, <a href="/A240857/b240857.txt">Rows n = 0..125 of triangle, flattened</a>
%F T(n,k) = A048881(n+k), 0 <= k <= n.
%e . 0: 0
%e . 1: 0 1
%e . 2: 1 0 1
%e . 3: 0 1 1 2
%e . 4: 1 1 2 0 1
%e . 5: 1 2 0 1 1 2
%e . 6: 2 0 1 1 2 1 2
%e . 7: 0 1 1 2 1 2 2 3
%e . 8: 1 1 2 1 2 2 3 0 1
%e . 9: 1 2 1 2 2 3 0 1 1 2
%e . 10: 2 1 2 2 3 0 1 1 2 1 2
%e . 11: 1 2 2 3 0 1 1 2 1 2 2 3
%e . 12: 2 2 3 0 1 1 2 1 2 2 3 1 2
%e . 13: 2 3 0 1 1 2 1 2 2 3 1 2 2 3
%e . 14: 3 0 1 1 2 1 2 2 3 1 2 2 3 2 3
%e . 15: 0 1 1 2 1 2 2 3 1 2 2 3 2 3 3 4 .
%t T[n_, k_] := DigitCount[n + k + 1, 2, 1] - 1; Table[T[n, k], {n, 0, 12}, {k, 0, n}] // Flatten (* _Amiram Eldar_, Aug 01 2023 *)
%o (Haskell)
%o a240857 n k = a240857_tabl !! n !! k
%o a240857_row n = a240857_tabl !! n
%o a240857_tabl = iterate (\(x:xs) -> xs ++ [x, x + 1]) [0]
%Y Cf. A048881 (left edge), A000120 (right edge), A000788 (row sums), A000523 (row maxima), A240883 (central terms).
%K nonn,tabl
%O 0,10
%A _Reinhard Zumkeller_, Apr 14 2014