A249642 Number of strings of length n over a 9-letter alphabet that begin with a nontrivial palindrome.
0, 0, 9, 153, 1449, 13617, 123129, 1113273, 10024569, 90266553, 812444409, 7312407993, 65812080249, 592312391937, 5330815197129, 47977369796313, 431796361188969, 3886167547854657, 34975508227845849, 314779576724952633, 2833016193198913689, 25497145762858874817
Offset: 0
Examples
For n=3 the a(3) = 153 valid strings are: 000, 001, 002, 003, 004, 005, 006, 007, 008, 010, 020, 030, 040, 050, 060, 070, 080, 101, 110, 111, 112, 113, 114, 115, 116, 117, 118, 121, 131, 141, 151, 161, 171, 181, 202, 212, 220, 221, 222, 223, 224, 225, 226, 227, 228, 232, 242, 252, 262, 272, 282, 303, 313, 323, 330, 331, 332, 333, 334, 335, 336, 337, 338, 343, 353, 363, 373, 383, 404, 414, 424, 434, 440, 441, 442, 443, 444, 445, 446, 447, 448, 454, 464, 474, 484, 505, 515, 525, 535, 545, 550, 551, 552, 553, 554, 555, 556, 557, 558, 565, 575, 585, 606, 616, 626, 636, 646, 656, 660, 661, 662, 663, 664, 665, 666, 667, 668, 676, 686, 707, 717, 727, 737, 747, 757, 767, 770, 771, 772, 773, 774, 775, 776, 777, 778, 787, 808, 818, 828, 838, 848, 858, 868, 878, 880, 881, 882, 883, 884, 885, 886, 887, 888
Links
- Peter Kagey, Table of n, a(n) for n = 0..1000
Crossrefs
Programs
-
Maple
A[0]:= 0: A[1]:= 0: for n from 1 to 99 do A[n+1]:= 9*A[n] + 9^ceil((n+1)/2) - A[ceil((n+1)/2)] od: seq(A[n],n=0..100); # Robert Israel, Dec 30 2014
-
Mathematica
a249642[n_] := Block[{f}, f[0] = f[1] = 0; f[x_] := 9*f[x - 1] + 9^Ceiling[x/2] - f[Ceiling[x/2]]; Table[f[i], {i, 0, n}]]; a249642[21] (* Michael De Vlieger, Dec 26 2014 *)
-
Ruby
seq = [0, 0]; (2..N).each{ |i| seq << 9 * seq[i-1] + 9**((i+1)/2) - seq[(i+1)/2] }
Formula
a(0) = 0; a(1) = 0; a(n+1) = 9*a(n) + 9^ceiling((n+1)/2) - a(ceiling((n+1)/2))
G.f. g(x) satisfies g(x) = 9*x^2*(1+9*x)/((1-9*x)*(1-9*x^2)) - (1+x)*g(x^2)/(x-9*x^2). - Robert Israel, Dec 30 2014
Comments