OFFSET
0,2
LINKS
Eric Rowland, The number of nonzero binomial coefficients modulo p^alpha, arXiv:1001.1783 [math.NT]
PROG
(Python)
import re
from gmpy2 import digits
def A387109(n):
s = digits(n, 3)
n1, n2, n10, n20, n21, n11 = s.count('1'), s.count('2'), s.count('10'), s.count('20'), s.count('21'), len(re.findall('(?=11)', s))
n100, n110, n120, n101, n111, n121 = s.count('100'), s.count('110'), s.count('120'), len(re.findall('(?=101)', s)), len(re.findall('(?=111)', s)), len(re.findall('(?=121)', s))
n200, n201, n210, n211, n220, n221 = s.count('200'), s.count('201'), s.count('210'), s.count('211'), s.count('220'), s.count('221')
c = 144*n10+63*n11+128*(n20+n220)+80*n21+864*n100+216*(n101+n110)+54*n111+96*n120+24*n121+1152*n200+288*(n201+n210+1)+72*n211+32*n221
c += (m:=4*n10+n11)*(96*n20+24*n21+9*m)+16*(4*n20+n21)**2
return (c*3**n2<<n1)//9>>5
CROSSREFS
KEYWORD
nonn
AUTHOR
Chai Wah Wu, Aug 16 2025
STATUS
approved
