login
Number of nonzero palindromes of length n (in base 3).
10

%I #40 Oct 28 2024 12:07:50

%S 2,2,6,6,18,18,54,54,162,162,486,486,1458,1458,4374,4374,13122,13122,

%T 39366,39366,118098,118098,354294,354294,1062882,1062882,3188646,

%U 3188646,9565938,9565938,28697814,28697814,86093442,86093442,258280326,258280326,774840978

%N Number of nonzero palindromes of length n (in base 3).

%C See A225367 for the sequence that counts all base 3 palindromes, including 0 (and thus also the number of n-digit terms in A006072). -- A nonzero 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, there are 2*3^(k-1) possibilities. - _M. F. Hasler_, May 05 2013

%C From _Gus Wiseman_, Oct 18 2023: (Start)

%C Also the number of subsets of {1..n} with n not the sum of two subset elements (possibly the same). For example, the a(0) = 1 through a(4) = 6 subsets are:

%C {} {} {} {} {}

%C {1} {2} {1} {1}

%C {2} {3}

%C {3} {4}

%C {1,3} {1,4}

%C {2,3} {3,4}

%C For subsets with no subset summing to n we have A365377.

%C Requiring pairs to be distinct gives A068911, complement A365544.

%C The complement is counted by A366131.

%C (End) [Edited by _Peter Munn_, Nov 22 2023]

%H <a href="/index/Rec#order_02">Index entries for linear recurrences with constant coefficients</a>, signature (0,3).

%F a(n) = 2*3^floor((n-1)/2).

%F a(n) = 2*A108411(n-1).

%F From _Colin Barker_, Feb 15 2013: (Start)

%F a(n) = 3*a(n-2).

%F G.f.: -2*x*(x+1)/(3*x^2-1). (End)

%e The a(3)=6 palindromes of length 3 are: 101, 111, 121, 202, 212, and 222. - _M. F. Hasler_, May 05 2013

%t With[{c=NestList[3#&,2,20]},Riffle[c,c]] (* _Harvey P. Dale_, Mar 25 2018 *)

%t Table[Length[Select[Subsets[Range[n]],!MemberQ[Total/@Tuples[#,2],n]&]],{n,0,10}] (* _Gus Wiseman_, Oct 18 2023 *)

%o (PARI) A117855(n)=2*3^((n-1)\2) \\ - _M. F. Hasler_, May 05 2013

%o (Python)

%o def A117855(n): return 3**(n-1>>1)<<1 # _Chai Wah Wu_, Oct 28 2024

%Y Cf. A050683 and A070252.

%Y Bisections are both A025192.

%Y A093971/A088809/A364534 count certain types of sum-full subsets.

%Y A108411 lists powers of 3 repeated, complement A167936.

%Y Cf. A004526, A004737, A008967, A038754, A046663, A167762, A365376, A366130.

%K nonn,base,easy,changed

%O 1,1

%A _Martin Renner_, May 02 2006

%E More terms from _Colin Barker_, Feb 15 2013