More Sierpiński’s Triangles inside Pascal’s Triangle? 🤯

David Banks
3 min readApr 9, 2023

--

Discovering yet more hidden in the seemingly dead zones!

image by DALL-E

Introduction

I’ve written a couple of articles on Sierpiński’s Triangle in the last couple of days. I thought that was it but yesterday I wondered what would happen if you had more pixel colours, selected over different modulos? I thought modulo 4 should be interesting as it’s a factor of two, so we should get the original structure but with some pattern within the true regions. Worth a try.

I’m not going to rehash the whole program again; you can copy and paste the complete code from here and see a full explanation of what it’s doing.

Sierpiński modulo 4

I altered the conditional that decides whether a pixel should be black or white to this.

let colour;
switch (modulo) {
case BigInt(0):
colour = 'blue';
break;
case BigInt(2):
colour = 'red';
break;
default:
colour = 'white';
break;
}
point.setAttribute('fill', colour);

The result.

Showing sub-fractals within Sierpiński’s Triangle

Amazing, I think, but it raises the question.

Can I also populate the remaining dead areas? Not completely.

Working with more colours

I extracted the colour choosing section into a function so that I could rewrite it to produce me an arbitrary number of colours.

function calculateColour(value, maxModulo) {
let colour = (BigInt(360) / BigInt(maxModulo - 1)) * value;
return `hsl(${colour}, 100%, 50%)`;
}

Moving up to eight colours now we get more filling.

With sixty-four colours. We can see much more filling, but there are areas that are uniform.

It seems that as we increase the MAX_MODULO these areas get fragmented and reduced in size whilst other areas become so complicated that one can no longer see the underlying fractal.

Further Analysis

I want to be able to hide and show selected modulos so that I can see which ones are affecting which regions. To achieve this, I’m going to add the results of each modulo to a g then create a wee helper function that’ll hide and show those groups which I can call from the browser console.

When I only display the odd numbered modulos I saw something I didn’t expect.

Odd numbered modulos only. Seem to define the outlines of the regions.

It looks to me like the odd numbered modulos tend to outline the left and right of the regions. It’s not exact, and I admit that I haven’t totally convinced myself that that is indeed what’s happening, however I think it’s a really lovely variation of the fractal.

--

--