OFFSET
0,3
COMMENTS
This sequence is the building block for the calculation of the sums of positive integers whose decimal notation only uses two distinct, nonzero digits. See the attached pdf document.
LINKS
Pierre-Alain Sallard, Integers sequences A328348 and A328350 to A328356
Index entries for linear recurrences with constant coefficients, signature (23,-62,40).
FORMULA
a(n) = (10*20^n - 19*2^n + 9)/171.
From Stefano Spezia, Oct 15 2019: (Start)
G.f.: x/(1 - 23*x + 62*x^2 - 40*x^3).
E.g.f.: (1/171)*exp(x)*(9 - 19*exp(x) + 10*exp(19*x)).
a(n) = 23*a(n-1) - 62*a(n-2) + 40*a(n-3) for n > 2.
(End)
a(n) = 21*a(n-1) - 20*a(n-2) + 2^(n-1) for n > 1. - Pierre-Alain Sallard, Dec 10 2019
EXAMPLE
For n=3, the sum of all positive integers whose decimal expansion contains only the digits 5 and 8 (then S=5+8=13) with at most n=3 such digits, i.e., the sum 5 + 8 + 55 + 58 + 85 + 88 + 555 + 558 + 585 + 588 + 855 + 858 + 885 + 888, is equal to a(3)*13=6071.
The formula is valid for any other choice of two distinct digits. Other examples: always with n=3 but let's say with the 2 and 3 digits (then S=2+3=5), the sum 2+3+22+23+32+33+222+223+232+233+322+323+332+333 is equal to a(3)*5=2335.
Or with the 6 and 7 digits (and which case S=6+7 is the same as with the 5 and 8 digits), the sum 6+7+66+67+...+776+777 is equal to a(3)*13=6071 (same sum as with the 5 and 8 digits).
PROG
(Python) [(10*20**n-19*2**n+9)/(9*19) for n in range(20)]
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Pierre-Alain Sallard, Oct 13 2019
STATUS
approved