A249639 Number of strings of length n over a 6 letter alphabet that begin with a nontrivial palindrome.
0, 0, 6, 66, 426, 2706, 16386, 99186, 595986, 3580986, 21490986, 128976186, 773887386, 4643505066, 27861211146, 167168350506, 1003011186666, 6018073616706, 36108448196946, 216650728156866, 1299904407916386, 7799426681319186, 46796560321735986
Offset: 0
Examples
For n=3 the a(3) = 66 solutions are: 000, 001, 002, 003, 004, 005, 010, 020, 030, 040, 050, 101, 110, 111, 112, 113, 114, 115, 121, 131, 141, 151, 202, 212, 220, 221, 222, 223, 224, 225, 232, 242, 252, 303, 313, 323, 330, 331, 332, 333, 334, 335, 343, 353, 404, 414, 424, 434, 440, 441, 442, 443, 444, 445, 454, 505, 515, 525, 535, 545, 550, 551, 552, 553, 554, 555
Links
- Peter Kagey, Table of n, a(n) for n = 0..1000
Crossrefs
Programs
-
Mathematica
a249639[n_] := Block[{f}, f[0] = f[1] = 0; f[x_] := 6*f[x - 1] + 6^Ceiling[x/2] - f[Ceiling[x/2]]; Table[f[i], {i, 0, n}]]; a249639[22] (* Michael De Vlieger, Dec 27 2014 *)
-
Ruby
seq = [0, 0]; (2..N).each{ |i| seq << 6 * seq[i-1] + 6**((i+1)/2) - seq[(i+1)/2] }
Formula
a(0) = 0; a(1) = 0; a(n+1) = 6*a(n) + 6^ceiling((n+1)/2) - a(ceiling((n+1)/2))
Comments