cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A006940 Rows of Pascal's triangle mod 3.

This page as a plain text file.
%I A006940 M4806 #22 Aug 01 2025 00:09:30
%S A006940 1,11,121,1001,11011,121121,1002001,11022011,121212121,1000000001,
%T A006940 11000000011,121000000121,1001000001001,11011000011011,
%U A006940 121121000121121,1002001001002001,11022011011022011,121212121121212121,1000000002000000001,11000000022000000011,121000000212000000121
%N A006940 Rows of Pascal's triangle mod 3.
%C A006940 Subsequence of A118594. - _Chai Wah Wu_, Jul 30 2025
%D A006940 C. Pickover, Mazes for the Mind, St. Martin's Press, NY, 1992, p. 353.
%D A006940 N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%t A006940 a[n_] := FromDigits[Table[Mod[Binomial[n, k], 3], {k, 0, n}]]; Array[a, 25, 0] (* _Amiram Eldar_, Nov 22 2018 *)
%o A006940 (PARI) a(n)=fromdigits(apply(x->x%3, binomial(n))); \\ _Michel Marcus_, Nov 21 2018
%o A006940 (Python)
%o A006940 from math import prod, comb
%o A006940 from gmpy2 import digits
%o A006940 def A006940(n):
%o A006940     if n==0: return 1
%o A006940     c, l = '', len(s:=digits(n,3))
%o A006940     for k in range(m:=n+2>>1):
%o A006940         t = digits(k,3).zfill(l)
%o A006940         c += str(prod(comb(int(s[i]),int(t[i]))%3 for i in range(l))%3)
%o A006940     return int(c+c[m-2+(n&1)::-1]) # _Chai Wah Wu_, Jul 30 2025
%Y A006940 Cf. A007318, A083093, A118594.
%K A006940 nonn
%O A006940 0,2
%A A006940 _N. J. A. Sloane_
%E A006940 More terms from _Michel Marcus_, Nov 21 2018