There are many ways to generalize them in 3D. Hope you’ll like my approach.
How it works:
The app visualizes a number N by recursively building a hierarchy of spheres based on its prime factors.
Given N with prime factors p_1, p_2, …, p_k: - Start with a single root sphere. - For the first factor p_1, place p_1 smaller spheres with their centers on the surface of the root. - For the next factor p_2, place p_2 even smaller spheres on the surface of each sphere from the previous level. - Repeat until all prime factors are used.
At the end, the number of smallest spheres is exactly N.
Sphere placement on each level is handled by a simple physics simulation using Coulomb-style repulsion, normalized by the size of spheres on the previous depth level, while keeping centers locked on the surface of the parent sphere. All spheres on the same depth level interact, not only those positioned on the same parent sphere. This way, spheres spread out evenly over the surface and in space. Sphere size is based on the minimum distance between spheres at the same level, scaled by an adjustable factor.
The code was written using Google Antigravity with the Gemini 3 Pro model.