A117855 Number of nonzero palindromes of length n (in base 3).
2, 2, 6, 6, 18, 18, 54, 54, 162, 162, 486, 486, 1458, 1458, 4374, 4374, 13122, 13122, 39366, 39366, 118098, 118098, 354294, 354294, 1062882, 1062882, 3188646, 3188646, 9565938, 9565938, 28697814, 28697814, 86093442, 86093442, 258280326, 258280326, 774840978
Offset: 1
Examples
The a(3)=6 palindromes of length 3 are: 101, 111, 121, 202, 212, and 222. - _M. F. Hasler_, May 05 2013
Links
- Index entries for linear recurrences with constant coefficients, signature (0,3).
Crossrefs
Programs
-
Mathematica
With[{c=NestList[3#&,2,20]},Riffle[c,c]] (* Harvey P. Dale, Mar 25 2018 *) Table[Length[Select[Subsets[Range[n]],!MemberQ[Total/@Tuples[#,2],n]&]],{n,0,10}] (* Gus Wiseman, Oct 18 2023 *)
-
PARI
A117855(n)=2*3^((n-1)\2) \\ - M. F. Hasler, May 05 2013
-
Python
def A117855(n): return 3**(n-1>>1)<<1 # Chai Wah Wu, Oct 28 2024
Formula
a(n) = 2*3^floor((n-1)/2).
a(n) = 2*A108411(n-1).
From Colin Barker, Feb 15 2013: (Start)
a(n) = 3*a(n-2).
G.f.: -2*x*(x+1)/(3*x^2-1). (End)
Extensions
More terms from Colin Barker, Feb 15 2013
Comments