login
A386952
Number of entries in the n-th row of Pascal's triangle not divisible by 9.
6
1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 8, 12, 9, 12, 15, 14, 16, 18, 7, 14, 21, 14, 19, 24, 21, 24, 27, 4, 8, 12, 12, 18, 24, 20, 28, 36, 9, 18, 27, 20, 28, 36, 31, 38, 45, 14, 28, 42, 28, 38, 48, 42, 48, 54, 7, 14, 21, 20, 31, 42, 33, 48, 63, 14, 28, 42, 31, 44, 57, 48
OFFSET
0,2
LINKS
James G. Huard, Blair K. Spearman, and Kenneth S. Williams, Pascal's triangle (mod 9), Acta Arithmetica, 78 (1997), 331-349.
MAPLE
P:= [1]; R:= 1:
for i from 1 to 100 do
P:= [1, op(P[2..-1]+P[1..-2] mod 9), 1];
v:=i+1 - numboccur(0, P):
R:= R, v;
od:
R; # Robert Israel, Sep 10 2025
PROG
(Python)
import re
from gmpy2 import digits
def A386952(n):
s = digits(n, 3)
n1 = s.count('1')
n2 = s.count('2')
n01 = s.count('10')
n02 = s.count('20')
n11 = len(re.findall('(?=11)', s))
n12 = s.count('21')
return ((3*((1+n01<<2)+n11)+((n02<<2)+n12<<2))*3**n2<<n1)//3>>2
CROSSREFS
KEYWORD
nonn
AUTHOR
Chai Wah Wu, Aug 10 2025
STATUS
approved