OFFSET
1,1
COMMENTS
Also: The number of n-digit terms in A006072. See there for further comments.
A palindrome of length L=2k-1 or of length L=2k is determined by the first k digits, which then determine the last k digits by symmetry. Since the first digit cannot be 0 (unless L=1), there are 2*3^(k-1) possibilities for L>1.
Except for the initial term, this is identical to A117855, which counts only nonzero palindromes.
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (0,3).
FORMULA
a(n) = 2*3^floor((n-1)/2) + [n=1].
a(n) = 3*a(n-2) for n>3.
G.f.: x*(3*x^2-2*x-3)/(3*x^2-1).
a(n) = (6-(1+(-1)^n)*(3-sqrt(3)))*sqrt(3)^(n-3) for n>1, a(1)=3. [Bruno Berselli, May 06 2013]
EXAMPLE
The a(1)=3 palindromes of length 1 are: 0, 1 and 2.
The a(2)=2 palindromes of length 2 are: 11 and 22.
MATHEMATICA
Join[{3}, LinearRecurrence[{0, 3}, {2, 6}, 40]] (* Vincenzo Librandi, May 31 2017 *)
PROG
(PARI) A225367(n)=2*3^((n-1)\2)+!n
(Magma) [n eq 1 select 3 else 2*3^Floor((n-1)/2): n in [1..40]]; // Bruno Berselli, May 06 2013
(Magma) I:=[3, 2, 6]; [n le 3 select I[n] else 3*Self(n-2): n in [1..40]]; // Vincenzo Librandi, May 31 2017
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
M. F. Hasler, May 05 2013
STATUS
approved