G. C. Greubel, <a href="/A143214/b143214_1.txt">Rows n = 1..50 of the triangle, flattened</a>
G. C. Greubel, <a href="/A143214/b143214_1.txt">Rows n = 1..50 of the triangle, flattened</a>
reviewed
approved
proposed
reviewed
editing
proposed
G. C. Greubel, <a href="/A143214/b143214_1.txt">Rows n = 1..50 of the triangle, flattened</a>
Edited by G. C. Greubel, Aug 27 2024
Gray code applied to Pascal's triangle: T(n,mk) = GrayCode(binomial(n,m k)).
Row sums are 1, 2, 5, 6, 19, 46, 58, 172, 235, 518, 790, ... .
T(n,m) = A003188(binomial(n,m)).
Triangle begins as:
1;
1, 1;
1, 3, 1;
1, 2, 2, 1;
1, 6, 5, 6, 1;
1, 7, 15, 15, 7, 1;
1, 5, 8, 30, 8, 5, 1;
1, 4, 31, 50, 50, 31, 4, 1;
1, 12, 18, 36, 101, 36, 18, 12, 1;
1, 13, 54, 126, 65, 65, 126, 54, 13, 1;
1, 15, 59, 68, 187, 130, 187, 68, 59, 15, 1;
GrayCodeList[k_] := Module[{b = IntegerDigits[k, 2], i}, Do[ If[b[[i - 1]] == 1, b[[i]] = 1 - b[[i]]], {i, Length[b], 2, -1} ]; b ]; FromGrayCodeList[d_] := Module[{b = d, i, j}, Do[ If[Mod[Sum[b[[j]], {j, i - 1}], 2] == 1, b[[i]] = 1 - b[[i]]], {i, n = Length[d], 2, -1} ]; FromDigits[b, 2] ]; GrayCode[i_, n_] := FromDigits[BitXor @@@ Partition[Prepend[ IntegerDigits[i, 2, n], 0], 2, 1], 2] FromGrayCode[i_, n_] := FromDigits[BitXor[IntegerDigits[i, 2, n], FoldList[ BitXor, 0, Most[IntegerDigits[i, 2, n]]]], 2]; Clear[f, a, n, m, x]; a = Table[Table[Binomial[n, m], {m, 0, n}], {n, 0, 10}] b=Table[Flatten[Table[GrayCode[a[[n]][[m]], 10], {m, 1, n}]], {n, 1, Length[ a]}]; Flatten[%]
(* program for a fractal picture modulo two: *)
c = Table[Table[If[m <= n, Mod[b[[n]][[m]], 2], 0], {m, 1, Length[b]}], {n, 1, Length[b]}]; ListDensityPlot[c, Mesh -> False]
(* The fractal pattern is the same for Pascal's triangle and the MacMahon numbers, A060187, but not for Eulerian numbers, A123125.*)
GrayCode[n_, k_]:= FromDigits[BitXor@@@Partition[Prepend[IntegerDigits[n, 2, k], 0], 2, 1], 2];
A143214[n_, k_]:= GrayCode[Binomial[n-1, k-1], 10];
Table[A143214[n, k], {n, 12}, {k, n}]//Flatten
approved
editing
editing
approved
Row sums are: 1, 2, 5, 6, 19, 46, 58, 172, 235, 518, 790, ... .
approved
editing
editing
approved
T(n,m) = GrayCodeA003188(binomial(n,m)).
{1},
1;
{1, 1},;
{1, 3, 1},;
{1, 2, 2, 1},;
{1, 6, 5, 6, 1},;
{1, 7, 15, 15, 7, 1},;
{1, 5, 8, 30, 8, 5, 1},;
{1, 4, 31, 50, 50, 31, 4, 1},;
{1, 12, 18, 36, 101, 36, 18, 12, 1},;
{1, 13, 54, 126, 65, 65, 126, 54, 13, 1},;
{1, 15, 59, 68, 187, 130, 187, 68, 59, 15, 1};
approved
editing