cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A225367 Number of palindromes of length n in base 3 (A118594).

This page as a plain text file.
%I A225367 #27 Jul 31 2025 22:03:17
%S A225367 3,2,6,6,18,18,54,54,162,162,486,486,1458,1458,4374,4374,13122,13122,
%T A225367 39366,39366,118098,118098,354294,354294,1062882,1062882,3188646,
%U A225367 3188646,9565938,9565938,28697814,28697814,86093442,86093442,258280326,258280326,774840978
%N A225367 Number of palindromes of length n in base 3 (A118594).
%C A225367 Also: The number of n-digit terms in A006072. See there for further comments.
%C A225367 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.
%C A225367 Except for the initial term, this is identical to A117855, which counts only nonzero palindromes.
%H A225367 Vincenzo Librandi, <a href="/A225367/b225367.txt">Table of n, a(n) for n = 1..1000</a>
%H A225367 <a href="/index/Rec#order_02">Index entries for linear recurrences with constant coefficients</a>, signature (0,3).
%F A225367 a(n) = 2*3^floor((n-1)/2) + [n=1].
%F A225367 a(n) = 3*a(n-2) for n>3.
%F A225367 G.f.: x*(3*x^2-2*x-3)/(3*x^2-1).
%F A225367 a(n) = (6-(1+(-1)^n)*(3-sqrt(3)))*sqrt(3)^(n-3) for n>1, a(1)=3. [_Bruno Berselli_, May 06 2013]
%e A225367 The a(1)=3 palindromes of length 1 are: 0, 1 and 2.
%e A225367 The a(2)=2 palindromes of length 2 are: 11 and 22.
%t A225367 Join[{3}, LinearRecurrence[{0, 3}, {2, 6}, 40]] (* _Vincenzo Librandi_, May 31 2017 *)
%o A225367 (PARI) A225367(n)=2*3^((n-1)\2)+!n
%o A225367 (Magma) [n eq 1 select 3 else 2*3^Floor((n-1)/2): n in [1..40]]; // _Bruno Berselli_, May 06 2013
%o A225367 (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
%o A225367 (Python)
%o A225367 def A225367(n): return 3 if n==1 else 3**(n-1>>1)<<1 # _Chai Wah Wu_, Jul 30 2025
%Y A225367 Cf. A050683 and A070252 for base 10 analogs.
%K A225367 nonn,base,easy
%O A225367 1,1
%A A225367 _M. F. Hasler_, May 05 2013