TITLE: Fill a cube with small cubes with different integer side lengths
QUESTION [6 upvotes]: We are given two (potentially unlimited) sets of cubes, say red cubes (with side $n$) and white cubes (with side $m$), with $m,n \in \mathbb{N} \setminus \{0\}, m \neq n$ (let's assume $n>m$).
Using the same number of red and white cubes, "build" a bigger cube, in the sense that this bigger cube is tessellated with the small cubes.
What is the minimum length $\mathfrak{L}_{n,m}$ of the side of the big cube (as a function of $m$ and $n$)? (How many small cubes are used?)
As noted by @achillehui, we have
$$ \mathfrak{L}_{an,am} = a \mathfrak{L}_{n,m}, \quad a \in \mathbb{N} \setminus \{0\},$$
so it suffices to consider the case $\text{gcd}(n,m)=1.$

$\mathfrak{L}_{n,m}^1 = \text{lcm}(l,\frac{L}{l^2}(m^3 + n^3))$ is a solution (check my answer below for the details)
$\mathfrak{L}_{n,m}^2 = n (m^3 + n^3)$ is a solution (due to @Logophobic)
$\mathfrak{L}_{n,m}^3 = m (m^3 + n^3)$ and $\mathfrak{L}_{n,m}^4 = 2m (m^3 + n^3)$ are solutions for some pairs $(n,m)$.

None of them is minimal, since we have
$$ \mathfrak{L}_{4,2}^1 = 36, \quad \mathfrak{L}_{4,2}^2 = 288 $$
while $\mathfrak{L}_{4,2} = 12$ is also a solution.

REPLY [2 votes]: Your solution is not minimal. I will provide a few examples.
I previously suggested that $\mathfrak{L} = m(m^3+n^3)$ is always a solution. That assumption proved false. However, $\mathfrak{L} = n(m^3+n^3)$ is a solution, though not always minimal.
Case $(n,m)=(3,2) : \mathfrak{L} = m(m^3+n^3) = 70$

Cube $70 \times 70 \times 70$ can be filled with $(m^3+n^3)^3=42,875$ cubes $m$
Replace $n^3(m^3+n^3)^2=33,075$ cubes $m$ with $m^3(m^3+n^3)^2=9,800$ cubes $n$
Cube $70 \times 70 \times 70$ then contains $9,800$ each of cubes $m$ and $n$

Case $(n,m)=(5,2) : \mathfrak{L} = n(m^3+n^3) = 665$

Cube $665 \times 665 \times 665$ can be filled with $(m^3+n^3)^3=2,352,637$ cubes $n$
Replace $m^3(m^3+n^3)^2=141,512$ cubes $n$ with $n^3(m^3+n^3)^2=2,211,125$ cubes $m$
Cube $665 \times 665 \times 665$ then contains $2,211,125$ each of cubes $m$ and $n$

Case $(n,m)=(4,2) : \mathfrak{L} = 12$

Cube $12 \times 12 \times 12$ can be filled with $27$ cubes $n$
Replace $3$ cubes $n$ with $24$ cubes $m$
Cube $12 \times 12 \times 12$ then contains $24$ each of cubes $m$ and $n$

I have revised my solution for $\mathfrak{L}_{n,m}=km$ to be stated more clearly. I have also taken into account achille hue's observation that $\mathfrak{L}_{dn,dm} = d\mathfrak{L}_{n,m}$ so this solution assumes $\text{gcd}(n,m)=1$
$$\mathfrak{L}_{dn,dm} = d\mathfrak{L}_{n,m}=kdm\\ \text{where $k$ is the least positive integer satisfying}\\(m^3+n^3)|k^3 \text{ and } \left\lfloor\frac{k}{n}\right\rfloor^3 \ge \frac{k^3}{(m^3+n^3)}$$
Unfortunately, this still does not guarantee a minimal solution because we could also find
$$\mathfrak{L}_{dn,dm} = d\mathfrak{L}_{n,m}=kdn\\ \text{where $k$ is the least positive integer satisfying}\\(m^3+n^3)|k^3 \text{ and } \left\lfloor\frac{k}{m}\right\rfloor^3 \ge \frac{k^3}{(m^3+n^3)}$$
Which will in some cases provide a more minimal solution. Case in point: $$\mathfrak{L}_{5,3}=38n=190 \lt \mathfrak{L}_{5,3}=76m=228$$
Proof that such cubes can be constructed:

Cube with edge length $kdm$ will have $\frac{(km)^3}{(m^3+n^3)}$ of each cube size.
This is an integer because $(m^3+n^3)|k^3$
The cube can be filled with $k^3$ cubes $dm$
$n^3$ cubes $dm$ in sub-cube with edge length $dnm$ can be replaced with $m^3$ cubes $dn$
This replacement must be repeated $\frac{k^3}{(m^3+n^3)}$ times so that the cube contains $\frac{(km)^3}{(m^3+n^3)}$ cubes $dn$
The replacement can be completed because $\left\lfloor\frac{k}{n}\right\rfloor^3 \ge \frac{k^3}{(m^3+n^3)}$

Using $\mathfrak{L}_{3,2}=35m$ as an example (this is the same as Case $(n,m) = (3,2)$ above.)

Cube with edge length $70$ will have $\frac{70^3}{35} = 9800$ of each cube
The cube can be filled with $35^3 = 42,875$ cubes $m$
$27$ cubes $m$ in sub-cube with edge length $6$ can be replaced with $8$ cubes $n$
This replacement must be repeated $\frac{35^3}{35} = 1225$ times so that the cube contains $9800$ cubes $n$
The replacement can be completed because $\left\lfloor\frac{35}{3}\right\rfloor^3 = 11^3 = 1331 \gt 1225$