login
Number of palindromes of length <= n.
6

%I #35 Jul 02 2023 09:35:18

%S 10,19,109,199,1099,1999,10999,19999,109999,199999,1099999,1999999,

%T 10999999,19999999,109999999,199999999,1099999999,1999999999,

%U 10999999999,19999999999,109999999999,199999999999,1099999999999,1999999999999,10999999999999,19999999999999

%N Number of palindromes of length <= n.

%H Colin Barker, <a href="/A070199/b070199.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,10,-10).

%F From _Colin Barker_, Jun 30 2012: (Start)

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

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

%F a(n) = (-2*sqrt(10)+10^(n/2)*(11+2*sqrt(10)+(-1)^n*(-11+2*sqrt(10))))/(2*sqrt(10)). - _Harvey P. Dale_, Mar 18 2016

%F From _Colin Barker_, Mar 17 2017: (Start)

%F a(n) = 2^(n/2 + 1)*5^(n/2) - 1 for n even.

%F a(n) = 11*10^((n-1)/2) - 1 for n odd. (End)

%F a(n) = A050250(n) + 1. - _Andrew Howroyd_, Oct 28 2020

%F E.g.f.: 2*cosh(sqrt(10)*x) - cosh(x) - 1 - sinh(x) + 11*sinh(sqrt(10)*x)/sqrt(10). - _Stefano Spezia_, Jul 01 2023

%t LinearRecurrence[{1,10,-10},{10,19,109},30] (* _Harvey P. Dale_, Mar 18 2016 *)

%o (PARI) Vec(x*(10+9*x-10*x^2)/((1-x)*(1-10*x^2)) + O(x^40)) \\ _Colin Barker_, Mar 17 2017

%Y Partial sums of A070252.

%Y Cf. A050250.

%K nonn,base,easy

%O 1,1

%A _N. J. A. Sloane_ and _Robert G. Wilson v_, May 14 2002