A213629 In binary representation: T(n,k) = number of (possibly overlapping) occurrences of k in n, triangle read by rows, 1<=k<=n.
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, 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, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 3, 1, 1, 0, 1, 1, 0, 0
Offset: 1
Examples
The triangle begins: . 1: 1 . 2: 1 1 . 3: 2 0 1 . 4: 1 1 0 1 . 5: 2 1 0 0 1 . 6: 2 1 1 0 0 1 . 7: 3 0 2 0 0 0 1 . 8: 1 1 0 1 0 0 0 1 . 9: 2 1 0 1 0 0 0 0 1 . 10: 2 2 0 0 1 0 0 0 0 1 . 11: 3 1 1 0 1 0 0 0 0 0 1 . 12: 2 1 1 1 0 1 0 0 0 0 0 1.
Links
- Reinhard Zumkeller, Rows n = 1..150 of triangle, flattened
- J.-P. Allouche, J. Shallit, The Ring of k-regular Sequences II, Example 4, p. 12
- Index entries for sequences related to binary expansion of n
Programs
-
Haskell
import Data.List (inits, tails, isPrefixOf) a213629 n k = a213629_tabl !! (n-1) !! (k-1) a213629_row n = a213629_tabl !! (n-1) a213629_tabl = map f $ tail $ inits $ tail $ map reverse a030308_tabf where f xss = map (\xs -> sum $ map (fromEnum . (xs `isPrefixOf`)) $ tails $ last xss) xss
-
Mathematica
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 *)
Comments