OFFSET
0,3
COMMENTS
This sequence is the building block for the calculation of the sums of positive integers whose decimal expansion contains only three distinct, nonzero digits: see attached pdf document.
LINKS
Pierre-Alain Sallard, Integers sequences A328348 and A328350 to A328356
Index entries for linear recurrences with constant coefficients, signature (34,-123,90).
FORMULA
a(n) = (20*30^n - 29*3^n + 9)/522.
From Stefano Spezia, Oct 17 2019: (Start)
O.g.f.: x/(1 - 34*x + 123*x^2 - 90*x^3).
E.g.f.: (1/522)*(9*exp(x) - 29*exp(3*x) + 20*exp(30*x)).
a(n) = 34*a(n-1) - 123*a(n-2) + 90*a(n-3) for n > 2. (End)
a(n) = 31*a(n-1) - 30*a(n-2) + 3^n for n > 1. - Pierre-Alain Sallard, Dec 15 2019
EXAMPLE
For n=2, the sum of all positive integers whose decimal expansions consist of at most n=2 of the digits 5, 6 or 7, i.e., the sum 5+6+7+55+56+57+65+66+67+75+76+77, is equal to a(2)*(5+6+7) = 612.
The formula is valid for any other choice of three distinct digits. Another example: again with n=2, but let's say with the digits 1, 2 and 3, the sum 1+2+3+11+12+13+21+22+23+31+32+33 is equal to a(2)*(1+2+3) = 204.
MATHEMATICA
Array[(20*30^# - 29*3^# + 9)/522 &, 20, 0] (* or *)
LinearRecurrence[{34, -123, 90}, {0, 1, 34}, 20] (* Paolo Xausa, Apr 29 2024 *)
PROG
(Python) [(20*30**n-29*3**n+9)//522 for n in range(20)]
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Pierre-Alain Sallard, Oct 13 2019
EXTENSIONS
Needs editing. - N. J. A. Sloane, Dec 12 2019
STATUS
approved