login
Number of palindromes (in base 7) below 7^n.
1

%I #28 Sep 08 2022 08:45:24

%S 6,12,54,96,390,684,2742,4800,19206,33612,134454,235296,941190,

%T 1647084,6588342,11529600,46118406,80707212,322828854,564950496,

%U 2259801990,3954653484,15818613942,27682574400,110730297606,193778020812,775112083254,1356446145696

%N Number of palindromes (in base 7) below 7^n.

%H G. C. Greubel, <a href="/A117866/b117866.txt">Table of n, a(n) for n = 1..1000</a>

%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (1,7,-7).

%F a(n) = 8*7^((n-1)/2)-2 (n odd), 2*7^(n/2)-2 (n even).

%F G.f.: 6*x*(x+1) / ((x-1)*(7*x^2-1)). - _Colin Barker_, Feb 15 2013

%F From _G. C. Greubel_, Oct 27 2016: (Start)

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

%F a(n) = (1/sqrt(7))*(-2*sqrt(7) + 7^((n+1)/2) + (-1)^n*7^((n+1)/2) + 4*7^(n/2) - 4*(-1)^n*7^(n/2)).

%F E.g.f.: (1/sqrt(7))*( (sqrt(7) - 4)*exp(-sqrt(7)*x) + (4 + sqrt(7))*exp(sqrt(7)*x) - 2*sqrt(7)*exp(x)). (End)

%t Table[If[OddQ[n],8*7^((n-1)/2)-2,2*7^(n/2)-2],{n,30}] (* or *) LinearRecurrence[{1,7,-7},{6,12,54},30] (* _Harvey P. Dale_, Oct 31 2013 *)

%t Rest@ CoefficientList[Series[6 x (x + 1)/((x - 1) (7 x^2 - 1)), {x, 0, 28}], x] (* _Michael De Vlieger_, Oct 31 2016 *)

%o (Magma) [IsOdd(n) select 8*7^((n-1) div 2)-2 else 2*7^(n div 2)-2: n in [1..30]]; // _Vincenzo Librandi_, Oct 29 2016

%o (PARI) a(n)=([0,1,0; 0,0,1; -7,7,1]^(n-1)*[6;12;54])[1,1] \\ _Charles R Greathouse IV_, Oct 31 2016

%Y Cf. A050250.

%K nonn,base,easy

%O 1,1

%A _Martin Renner_, May 02 2006

%E More terms from _Colin Barker_, Feb 15 2013