• Remix
  • Share
  • New Entry

  • Eric Ogier

  • /
  • Sierpinski triangle from Pascal triangle

on 27 Oct 2021
  • 6
  • 109
  • 0
  • 0
  • 212
N=18;
M=~mod(pascal(N),2);
B=1:N;
[I,J]=meshgrid(B,B);
gca;
hold on;
axis off;
arrayfun(@(i,j)t(i,j,M(i,j),N),I,J);
function t(i,j,m,N)
if i+j<N
x=[-.5 0 .5]*2;
y=[-.5 .5 -.5];
patch(x+i-j,y-i-j,1:3,m*[1 1 1],'edgecolor','none');
end
end
Remix Tree