w1[x_]:=(Translate[Scale[x,.5],{0,.5}]);
w2[x_]:=Scale[x,.5];
w3[x_]:=(Translate[Scale[x,.5],{.5,0}]);
W[a_]:=Union[{w1[a],w2[a],w3[a]}]
Graphics[{Nest[W,Polygon[{{0,0},{0,1},{1,1},{1,0}}],1]}]

x[a_,b_,x_,p_] := (Translate[Scale[x,1/p],{a/p,b/p}]);
X[v_,p_] := Table[x[i,j,v,p],{j,0,p-1},{i,0,p-1-j}]
Y[v_] := X[v,2]
Manipulate[Graphics[{Nest[Y,Polygon[{{0,0},{0,1},{1,1},{1,0}}],n]}],{n,0,8,1}]

L = Table[0,{i,64}];
L[[1]] = 1;
ArrayPlot[CellularAutomaton[60,L,63],Frame->False]

ArrayPlot[CellularAutomaton[30, {{1}, 0}, {200,Automatic}],Frame->False]

pascalTriangle[n_]:=NestList[{1,Sequence@@Plus@@@Partition[#,2,1],1}&,{1},n-1];
Column[Grid[{#},ItemSize->3]&/@(pascalTriangle[7]/.x_Integer:>Text[Style[x,Large,If[Mod[x,2]==0,Red,Black]]]),Center]

ArrayPlot[Mod[pascalTriangle[66],3],ColorRules-> {0->White,1-> Black,2-> Black,3-> Blue,4-> Red,5-> Black}]

ArrayPlot[Mod[pascalTriangle[66],6],ColorRules-> {0->White,1-> Black,2-> Black,3-> Black,4-> Black,5-> Black}]

Clear["`*"]

session = StartExternalSession["Python"]

carry = ExternalFunction[session,"def carry(a, b, p):
    carry = 0
    count = 0

    while len(a) is not 0 or len(b) is not 0:
        x = 0
        y = 0
        if len(a) > 0:
            x = a[-1]
            del a[-1]
        if len(b) > 0:
            y = b[-1]
            del b[-1]
        sum = x + y + carry

        if sum >= p:
            carry = int(sum/p)
            count += 1
        else:
            carry = 0
    return count"]

cp[n_,k_,p_] := carry[IntegerDigits[n,p],IntegerDigits[k,p],p]

cp[0,7,2]

FactorInteger[Binomial[220,50]]

MatrixForm[Table[{i,j},{i,0,10},{j,0,i}]]

ArrayPlot[Table[If[Or[cp[i-j,j,2]==0, cp[i-j,j,3] == 0],1,0],{i,0,100},{j,0,i}]]

ArrayPlot[Table[Table[Mod[Binomial[j+i,j],31],{i,0,256}],{j,0,256}],DataReversed->True]

BinomialMod[n_,k_,p_]:=With[{d=Max[IntegerLength[n,p],IntegerLength[k,p]]},Mod[Apply[Times,Mod[Thread[Binomial[IntegerDigits[n,p,d],IntegerDigits[k,p,d]]],p]],p]]

a1 = ArrayPlot[Table[Table[If[Or[cp[i,j,2]==0,False],1,0],{i,0,60}],{j,0,60}],DataReversed->True,ColorRules->{1 -> Red, 0->White}]

a2 = ArrayPlot[Table[Table[If[Or[cp[i,j,3]==0,False],1,0],{i,0,60}],{j,0,60}],DataReversed->True,ColorRules->{1 -> Blue, 0->White}]

ArrayPlot[Table[Table[If[Or[cp[i,j,2]==0,cp[i,j,3]==0 ],1,0],{i,0,60}],{j,0,60}],DataReversed->True,ColorRules->{1 -> Black, 0->White}]

ArrayPlot[Table[If[x+y == BitXor[x,y],{1},{0}],{x,0,1023},{y,0,1023}],DataReversed->True,Frame->False,Frame->False]

r[x_] := 1+x;

p2 = ArrayPlot[Table[Mod[CoefficientList[r[x]^n,x],2],{n,0,63}],PlotLegends->Automatic,Frame->False]

Export["test.pdf",p2]

RulePlot[CellularAutomaton[{5421,3,1/2}],Frame->False]

ArrayPlot[{{1,0,1,1,1,0,1,0,0,0,1,0,1,0,0}},Mesh->All]

RulePlot[CellularAutomaton[60],Frame-> False]

p1 = RulePlot[CellularAutomaton[60],{{1},0},20,PlotLegends->"Icon",Frame->False,Mesh->All]

xticks=Transpose[{Range@8, IntegerString[Range[0,7],2]}];
ytics = Transpose[{Range@8, IntegerString[Range[7,0,-1],2]}];

ArrayPlot[Mod[Array[Binomial,{8,8},0],2],Mesh->True,Frame->True,FrameStyle->Opacity[0],FrameTicksStyle->Opacity[1],FrameTicks->{ytics,xticks}]

carryfun[a_,b_,p_]:=Module[{carry=0,count=0,sum=0,aa=IntegerDigits[a,p],bb=IntegerDigits[b,p]},
While[Or[Length[aa]≠0,Length[bb]≠0],{x=0,y=0,If[Length[aa]>0,{x=aa[[-1]],aa=Drop[aa,-1]}],If[Length[bb]>0,{y=bb[[-1]],bb=Drop[bb,-1]}],sum=x+y+carry,If[sum≥p,{carry=Floor[sum/p],count++},carry=0]}];count]

fastcarry[a_,b_,p_]:=IntegerExponent[Binomial[a+b,b],p]

ArrayPlot[Table[Boole[fastcarry[i-j,j,2]==0],{i,0,500},{j,0,i}]]