I have the following question. I want to stack differently sized circles into a square/rectangle in a pyramid pattern and write code that can calculate the amount of circles in it. Kind of like this.
But I don't know how to go about it. Thanks to a question I asked a few days ago I was able to understand and use this formula that calculates the amount of circles vertically stacked if the circles were all the same size. (d = diameter, a = length of the square)
How would I go about adapting this to different diameters?
To clarify, I want to create this kind of pattern but with differently shaped circles.


