Code based 3d multiple cube instantiation

Hey guys, I have an idea I’m looking for a little bit of input on.

I’m in the midst of making a game where I want to generate a giant 3d cube. This cube would be made up of smaller individual cubes equidistant from each other, say for sake of argument 50px. So basically you would see a vast amount of cubes acting as one to form a greater object.

I have several ideas on how to tackle this, but I’m trying for smaller. I’m almost certain I can achieve what I want by setting up one base position and having everything spawn/instantiate out from that point; say with several for loops. However, the mathematics involved in this seriously hurt my head.

I was wondering if anyone would be kind enough to help out? It would be greatly appreciated.

Thanks.

// (x, y, z) is the starting position
for(int i=0; i<row; i++)
{
for(int j=0; j<column; j++)
{
for(int k=0; k<depth; k++)
{
//instantiate
//cube position = (x + idistanceBetweenCube, y + jdistanceBetweenCube, z + k*distanceBetweenCube)
}
}
}