login
A367243
a(n) is the number of n-digit numbers whose difference between the largest and smallest digits is equal to 2.
7
0, 15, 91, 381, 1375, 4605, 14791, 46341, 142975, 436845, 1326391, 4010901, 12096175, 36415485, 109500391, 329009061, 988042975, 2966160525, 8902544791, 26715760821, 80163535375, 240523111965, 721634347591, 2165033066181, 6495359245375, 19486597829805, 58460833676791
OFFSET
1,2
COMMENTS
a(n) is the number of n-digit numbers in A366959.
FORMULA
a(n) = (46*3^n - 93*2^n + 48)/6.
a(n) = 6*a(n-1) - 11*a(n-2) + 6*a(n-3) for n > 3.
O.g.f.: x^2*(15 + x)/((1 - x)*(1- 2*x)*(1 - 3*x)).
E.g.f.: (exp(x) - 1)^2*(46*exp(x) - 1)/6.
MATHEMATICA
LinearRecurrence[{6, -11, 6}, {0, 15, 91}, 27]
KEYWORD
nonn,base,easy
AUTHOR
Stefano Spezia, Nov 11 2023
STATUS
approved