%I #15 Oct 27 2024 06:11:28
%S 1,1,1,2,0,1,1,1,0,1,2,1,0,0,1,2,1,1,0,0,1,3,0,2,0,0,0,1,1,1,0,1,0,0,
%T 0,1,2,1,0,1,0,0,0,0,1,2,2,0,0,1,0,0,0,0,1,3,1,1,0,1,0,0,0,0,0,1,2,1,
%U 1,1,0,1,0,0,0,0,0,1,3,1,1,0,1,1,0,0
%N In binary representation: T(n,k) = number of (possibly overlapping) occurrences of k in n, triangle read by rows, 1<=k<=n.
%C The definition is based on the definition of pattern functions in the paper of Allouche and Shallit;
%C sum of n-th row = A029931(n);
%C T(n,1) = A000120(n);
%C T(n,2) = A033264(n) for n > 1;
%C T(n,3) = A014081(n) for n > 2;
%C T(n,4) = A056978(n) for n > 3;
%C T(n,5) = A056979(n) for n > 4;
%C T(n,6) = A056980(n) for n > 5;
%C T(n,7) = A014082(n) for n > 6;
%C T(n,k) = 0 for k with floor(n/2) < k < n;
%C T(n,n) = 1;
%C A122953(n) = Sum_{k=1..n} A057427(T(n,k));
%C A005811(n) = T(n,1) + T(n,2) - T(n,3);
%C A007302(n) = A000120(n) - sum (A213629(n,A136412(k))).
%H Reinhard Zumkeller, <a href="/A213629/b213629.txt">Rows n = 1..150 of triangle, flattened</a>
%H J.-P. Allouche, J. Shallit, <a href="http://www.math.jussieu.fr/~allouche/kreg2.ps">The Ring of k-regular Sequences II, Example 4, p. 12</a>
%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%e The triangle begins:
%e . 1: 1
%e . 2: 1 1
%e . 3: 2 0 1
%e . 4: 1 1 0 1
%e . 5: 2 1 0 0 1
%e . 6: 2 1 1 0 0 1
%e . 7: 3 0 2 0 0 0 1
%e . 8: 1 1 0 1 0 0 0 1
%e . 9: 2 1 0 1 0 0 0 0 1
%e . 10: 2 2 0 0 1 0 0 0 0 1
%e . 11: 3 1 1 0 1 0 0 0 0 0 1
%e . 12: 2 1 1 1 0 1 0 0 0 0 0 1.
%t t[n_, k_] := (idn = IntegerDigits[n, 2]; idk = IntegerDigits[k, 2]; ln = Length[idn]; lk = Length[idk]; For[cnt = 0; i = 1, i <= ln - lk + 1, i++, If[idn[[i ;; i + lk - 1]] == idk, cnt++]]; cnt); Table[t[n, k], {n, 1, 14}, {k, 1, n}] // Flatten (* _Jean-François Alcover_, Oct 22 2012 *)
%o (Haskell)
%o import Data.List (inits, tails, isPrefixOf)
%o a213629 n k = a213629_tabl !! (n-1) !! (k-1)
%o a213629_row n = a213629_tabl !! (n-1)
%o a213629_tabl = map f $ tail $ inits $ tail $ map reverse a030308_tabf where
%o f xss = map (\xs ->
%o sum $ map (fromEnum . (xs `isPrefixOf`)) $ tails $ last xss) xss
%Y Cf. A030308, A007088.
%K nonn,base,tabl,changed
%O 1,4
%A _Reinhard Zumkeller_, Jun 17 2012