<s>[INST] Find two numbers whose sum is 20 and LCM is 24 With some guess work I found the answers to be 8 and 12.
But is there any general formula for this?
Note that the question is asked to my nephew who is at 4th grade.
 [/INST] A general algorithm
If $a+b = n$ and $\mathrm{lcm}(a,b) = c$ we let $\gcd(a,b) = d$ to get
$$ab = cd\\
n = a+b$$
Solving $b = n-a$ gives us
$$a(n-a) = cd \\
\Leftrightarrow a^2-na + cd = 0 \\
\Leftrightarrow a = \frac n2 \pm \sqrt{\frac{n^2}4 - cd}$$
So for even $n$ we must find $d$ such that $\frac{n^2}4 - cd$ is a perfect square (since $c>0$ this will amount to a finite number of possibilities). The $\pm$ is irrelevant because $b$ will take the alternate value.
If $n$ is odd, $n^2 - 4cd$ must be a perfect square instead and we obtain an analogous formula:
$$a = \frac12 (n \pm \sqrt{n^2 - 4cd})$$
In both cases, $d$ can range between $1$ and $\left\lfloor \frac{n^2}{4c} \right\rfloor$
Your case thus allows $1\le d\le \lfloor\frac{400}{96}\rfloor = 4$ and $100-24d$ must be a perfect square. $d=4$ yields $4 = 2^2$ so
$$a = 10 + \sqrt{4} = 12; \quad b = 10 - \sqrt4 = 8$$
</s>