A117862 Number of palindromes (in base 3) below 3^n.
0, 2, 4, 10, 16, 34, 52, 106, 160, 322, 484, 970, 1456, 2914, 4372, 8746, 13120, 26242, 39364, 78730, 118096, 236194, 354292, 708586, 1062880, 2125762, 3188644, 6377290, 9565936, 19131874, 28697812, 57395626, 86093440, 172186882, 258280324, 516560650, 774840976
Offset: 0
Links
- G. C. Greubel, Table of n, a(n) for n = 0..1000
- Index entries for linear recurrences with constant coefficients, signature (1,3,-3).
Crossrefs
Cf. A050250.
Programs
-
Mathematica
Table[If[OddQ[n], 4*3^((n - 1)/2) - 2, 2*3^(n/2) - 2], {n,25}] (* or *) LinearRecurrence[{1,3,-3},{2, 4, 10},25] (* G. C. Greubel, Oct 27 2016 *)
-
PARI
apply( {A117862(n)=3^(n\2)<<(1+n%2)-2}, [0..44]) \\ M. F. Hasler, Jul 28 2021
Formula
a(n) = 4*3^((n-1)/2)-2 (n odd), 2*3^(n/2)-2 (n even).
G.f.: 2*x*(x+1) / ((x-1)*(3*x^2-1)). - Colin Barker, Feb 15 2013
Extensions
More terms from Colin Barker, Feb 15 2013
Extended to offset 0 by M. F. Hasler, Jul 28 2021