OFFSET
1,1
COMMENTS
a(n) is the number of terms between 10^(n-1) and 10^n in A353181.
LINKS
Zhining Yang, Table of n, a(n) for n = 1..300
Project Euler, Problem 788, Dominating Numbers
FORMULA
a(n) = Sum_{k=floor(n/2)+1..n} C(n,k)*9^(n-k+1) (thanks to Zhao Hui Du for help in the derivation of this formula).
a(n+3) = (-(5400+8280*n+2880*n^2)*a(n)+(360+828*n+288*n^2)*a(n+1)+(228+310*n+80*n^2)*a(n+2))/(21+31*n+8*n^2)) (thanks to Xianwen Wang for help in the derivation of this formula).
EXAMPLE
a(2)=9 because there are 9 numbers whose digits are the same, more than half of the length 2.
MATHEMATICA
a[n_]:=Sum[Binomial[n, k]9^(n-k+1), {k, Floor[n/2]+1, n}]; Array[a, 24] (* Stefano Spezia, Apr 29 2022 *)
PROG
(Python)
import math
def a(n):
return (sum(math.comb(n, i)*9**(n-i+1) for i in range(n//2+1, n+1)))
print([a(n) for n in range(1, 31)])
(Python)
def a(n):
r=[0, 9, 9]
for i in range(n):
r.append(-((5400+8280*i+2880*i*i)*r[i]+(-360-828*i-288*i*i)*r[i+1]+(-228-310*i-80*i*i)*r[i+2])//(21+31*i+8*i*i))
return r[n]
print([a(i) for i in range(1, 21)]) # Xianwen Wang, May 02 2022
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Zhining Yang, Apr 29 2022
STATUS
approved