A221235 Number of nonnegative integer arrays of length n summing to n without adjacent equal values.
1, 1, 2, 7, 14, 30, 76, 188, 444, 1075, 2656, 6504, 15926, 39316, 97252, 240597, 596686, 1482971, 3689768, 9191590, 22927718, 57253334, 143101896, 358003469, 896391914, 2246149936, 5632310800, 14132640565, 35483595966, 89141668532, 224061612932, 563473301874
Offset: 0
Keywords
Examples
All solutions for n=3 ..1....2....0....2....0....0....1 ..2....1....3....0....2....1....0 ..0....0....0....1....1....2....2
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..500 (first 210 terms from R. H. Hardin)
Crossrefs
Cf. A106351.
Programs
-
Maple
b:= proc(n, h, t) option remember; `if`(t<2, `if`(n<>h, 1, 0), add(`if`(h=j, 0, b(n-j, `if`(j>n-j, -1, j), t-1)), j=0..n)) end: a:= n-> b(n, -1, n): seq(a(n), n=0..35); # Alois P. Heinz, Oct 15 2017
-
Mathematica
b[n_, h_, t_] := b[n, h, t] = If[t < 2, If[n != h, 1, 0], Sum[If[h == j, 0, b[n-j, If[j > n-j, -1, j], t-1]], {j, 0, n}]]; a[n_] := b[n, -1, n]; Table[a[n], {n, 0, 35}] (* Jean-François Alcover, Apr 28 2022, after Alois P. Heinz *)
Formula
a(n) = A106351(2n,n). - Alois P. Heinz, Oct 12 2017
Extensions
a(0)=1 prepended by Alois P. Heinz, Oct 15 2017