login
A328348
Let S be any integer in the range 3 <= S <= 17. Sequence has the property that a(n)*S is the sum of all positive integers whose decimal expansion has <= n digits and contains at most two distinct nonzero digits p and q such that p+q=S.
8
0, 1, 23, 467, 9355, 187131, 3742683, 74853787, 1497075995, 29941520411, 598830409243, 11976608186907, 239532163742235, 4790643274852891, 95812865497074203, 1916257309941516827, 38325146198830402075, 766502923976608172571, 15330058479532163713563, 306601169590643274795547
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.
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)]
KEYWORD
nonn,base
AUTHOR
STATUS
approved