login
A383305
a(n) is number of n-digit nonnegative integers whose difference between the largest and smallest digits is equal to the arithmetic mean of its digits.
2
1, 6, 39, 266, 1730, 11361, 74809, 494194, 3273132, 21730506, 144588345, 964050593, 6440655572, 43111601819, 289112380019, 1942335481170, 13072051432742, 88125501965430, 595077180675348, 4024698113281006, 27261843502415806, 184931926767687963, 1256249015578188517, 8545135121520262849, 58198759816476208605
OFFSET
1,2
MATHEMATICA
a[n_]:=Module[{c=KroneckerDelta[n, 1]}, For[k=10^(n-1), k<=10^n, k++, If[Max[d=IntegerDigits[k]]-Min[d]==Mean[d], c++]]; c]; Array[a, 7]
PROG
(Python)
def A383305(n):
if n<=1: return n
s={(k, k, k):1 for k in range(1, 10)}
for i in range(n-1):
snew={}
for (h, l, t), v in s.items():
for d in range(10):
p=(max(h, d), min(l, d), t+d)
if p in snew:
snew[p]+=v
else:
snew[p]=v
s=snew
return sum( v for (h, l, t), v in s.items() if n*(h-l)==t) # Bert Dobbelaere, Apr 25 2025
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Stefano Spezia, Apr 22 2025
EXTENSIONS
More terms from Bert Dobbelaere, Apr 25 2025
STATUS
approved