OFFSET
0,2
COMMENTS
a(n) is a multiple of A001316(n). - Chai Wah Wu, Jun 26 2025
LINKS
John Tyler Rascoe, Table of n, a(n) for n = 0..8192
James G. Huard, Blair K. Spearman, and Kenneth S. Williams, Pascal's triangle (mod 8), European Journal of Combinatorics 19:1 (1998), pp. 45-62.
Chai Wah Wu, Sum of rows of Pascal's triangle modulo 8, blog post.
MATHEMATICA
A385285[n_] := Sum[Mod[Binomial[n, k], 8], {k, 0, n}];
Array[A385285, 100, 0] (* Paolo Xausa, Jun 26 2025 *)
PROG
(PARI) a(n) = sum(k=0, n, binomial(n, k) % 8); \\ Michel Marcus, Jun 26 2025
(Python)
def A385285(n):
if n==0: return 1
s = '0'+bin(n)[2:]
n1 = n>>1
n2 = n1>>1
n3 = n2>>1
np = ~n
n1111 = (n3&n2&n1&n).bit_count()
n11 = (n1&n).bit_count()
n101 = (n2&(~n1)&n).bit_count()
n100 = (n2&(~n1)&np).bit_count()
n110 = (n2&n1&np).bit_count()
n10 = (n1&np).bit_count()
n1100 = (n3&n2&(~n1)&np).bit_count()
m11 = s.count('0110')
m111 = s.endswith('0111')
c = (n100<<2)+n110+(n10*(n10-1)>>1)
if n11==0:
c += n10+(n100<<1)
elif n11==1:
c += (n10-n1100<<1)+n110
else:
c += n10<<1
if not (n1111 or n11 or n101):
c += 1
elif not (n1111 or n11) and n101:
c += 3
elif m111:
c += 4
elif not (n1111 or n101 or m11) and n11:
c += 2
else:
c += 4
return c<<n.bit_count() # Chai Wah Wu, Jun 26 2025
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Peter Luschny, Jun 26 2025
STATUS
approved
