table[n_] := Table[0, {i,1, n}, {j,1, n}, {k, 1, n}]

procedure[n_] := 
{colorCube = table[n]; 
For[i=1, i<n+1, i++,
For[j=1, j<n+1, j++,
For[k =1, k< n+1,  k++,
colorCube[[i,j,k]] = {i/n, j/n, k/n} ]]];}

procedure[5]

Graphics3D[Raster3D[colorCube], Boxed-> False]

colorCube

procedure[50]

nicerCube = Graphics3D[Raster3D[colorCube], Boxed -> False]