Here is a way to visualize the factorisation of natural numbers. How do we get this or a similar kind of output using Mathematica?
See the list of images generated for number from 1 to 36:
Let me introduce the following animated approach:
As you can see, I've slightly changed the way of diagram generation. The main differences are the following.
1. Now the diagrams are more symmetric. This is due to proper rotation after each sudivision.
2. As the main principle is to use factors in decreasing order, I consider 4 as a separate factor and place it before 3.
It is also should be noted that the total area of dots in each diagram is constant.
And finally one more factoring movie for 420:
I've modified the rules of diagram generation regarding Andrew's comment below. Now the factoring is mathematically strict in a sense that 4 is not considered prime like above.
Here is the animatied version.
I've also cleaned the code but still it needs some tweaking which I don't have time for.
And finally this is the modified version of factoring 420.
This is Andrew's method with a few tweaks of my own. The addition of the adjustment argument should make other customization a bit easier.
Here's my modest attempt:
Here is a recursive method using Outer:
Some manual tweaking will be required to get the same layout as in your example above. In particular, the special case
Then you get very close, except for some choices about orientation of each piece: