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.

  • 1
    $\begingroup$ No, but it's certainly possible to write down an algorithm. $\endgroup$ – Simon S Feb 11 '15 at 16:03
  • $\begingroup$ I would guess that if the question was asked to a 4th-grade student, then the intention was for him to find the answer using trial & error, rather than developing a general-case formula for this. Nevertheless, it should be interesting to see if such formula exists (which, BTW, @SimonS: to the best of my knowledge, every deterministic algorithm can be converted to a formula). $\endgroup$ – barak manos Feb 11 '15 at 16:08
  • 1
    $\begingroup$ @barakmanos Only if you know when the algorithm will terminate. Try to come up with a general formula for Newton's method for example ;) $\endgroup$ – AlexR Feb 11 '15 at 16:10
  • $\begingroup$ @AlexR: I might give it a try, but it should be interesting to post it as a question (I'm willing to bet that someone here will come up with an answer faster than you think). $\endgroup$ – barak manos Feb 11 '15 at 16:11
  • 1
    $\begingroup$ Depending on the conventions adopted for an LCM involving negative numbers, -4 and 24 could be another solution. $\endgroup$ – Peter Taylor Feb 12 '15 at 12:32

With 4th grade knowledge in mind, I would say this question is about finding all the factors of $24$, because the two numbers must both be factors of $24$ or they would have a different least common multiple.

So listing the factors of $24$ we get $1,2,3,4,6,8,12,24$. Then it's easy to see which two add to $20$, although you could certainly use the exercise, if so inclined, to develop a few more rules for harder cases, and in another case you might need to be a little careful that the least common multiple is indeed still $24$.

Another approach: $\frac{20}{24} = \frac{5}{6}$ - can we write $\frac{5}{6}$ as the sum of two unit fractions? The answer is yes, $\frac{1}{2} + \frac{1}{3}$, and the numbers we seek are $\frac{24}{2}=12$ and $\frac{24}{3}=8$

  • $\begingroup$ This is I find the easiest way to explain it :). Thanks $\endgroup$ – Tanmoy Feb 11 '15 at 16:42
  • 1
    $\begingroup$ @Tanmoy you're welcome; I added a link to Egyptian fractions for the alternative approach, might be of interest for your nephew. $\endgroup$ – Joffan Feb 11 '15 at 16:43
  • 2
    $\begingroup$ Except that in general, picking two factors of 24 doesn't mean that their LCM is 24. $\endgroup$ – Hao Ye Feb 12 '15 at 1:42
  • 1
    $\begingroup$ @HaoYe which in fact I say at the end of the second paragraph. The point is that picking numbers other than the factors of $24$ will guarantee that the LCM is not 24. $\endgroup$ – Joffan Feb 12 '15 at 2:42
  • $\begingroup$ My bad - must have missed that part of the sentence. $\endgroup$ – Hao Ye Feb 12 '15 at 2:53

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$$

  • $\begingroup$ Thanks for the general algorithm though I would go for @Jon's way to explain to a 4th grader but this answer satisfy my curiosity. $\endgroup$ – Tanmoy Feb 11 '15 at 16:33

With an LCM of 24 one of the numbers must be 8, as $2^3$ divides 24. It can't be 16 as 16 does not divide 24.

  • $\begingroup$ Why can't the number be less than 2^3? Like 4 or even 2? $\endgroup$ – Tanmoy Feb 11 '15 at 16:17
  • 2
    $\begingroup$ @Tanmoy: Because the LCM would be smaller. One of the numbers needs to contribute a factor $2^3$ $\endgroup$ – Ross Millikan Feb 11 '15 at 16:20
  • 1
    $\begingroup$ Note that the argument is only correct because $24 = 2^3\cdot 3$ so if $8$ was not one number, one had to be $24 > 20$ which contradicts that their sum is $20$. $\endgroup$ – AlexR Feb 11 '15 at 16:35
  • $\begingroup$ @AlexR, that depends on what you consider to be the value of $\textrm{lcm}(-4, 24)$. $\endgroup$ – Peter Taylor Feb 12 '15 at 11:55
  • $\begingroup$ @PeterTaylor Why would it be any different from $24$? If we allow integer arguments, we must allow integer multipliers and define $\mathrm{lcm}:\mathbb Z^2 \to \mathbb N$ for uniqueness. $\endgroup$ – AlexR Feb 12 '15 at 12:01

You want two factors of $24$ that add up to $20$. That means one factor must be less than or equal to $10$ (i.e. $20/2$), and the other must be between $10 $ and $20$ (inclusive) since it is equal to the first subtracted from $20$.

The only factor of $24$ between $10$ and $20$ inclusive is $12$. $20-12 = 8$. $8$ is a factor.

So the solution is $8$ and $12$.


Let $x$ and $y$ be the numbers. Note that $xy$ is the product of the LMC and the gcd, say, $d$. Then: $$xy=24d$$ $$x+y=20$$

I don't know if at 4th grade the pupils are supposed to be able of solve systems. If it is the case, you can write $$y=20-x$$ and then $$x(20-x)=24d$$

Solve $x$ to get $$x=\frac{20\pm\sqrt{400-96d}}2=10\pm2\sqrt{25-6d}$$

Therefore, $25-6d$ must be a perfect square. This only happens if $d=4$, which yields $x=8$ or $x=12$.

This is not a formula, but it makes the search much easier.


Let the numbers be $a,b$ and let $\gcd=d$,

then $a=pd, b=qd$


also $a.b=(l.c.m)(\gcd) $

or, $pqd^2=(l.c.m)(d)$, or, $l.c.m=pqd=24$

dividing the two equations we get,



$5$ does not divide $6$, therefore, $5$ divides$(p+q)$, also, $p+q$ does not divide pq, or, $p+q$ divides $5$, $\implies$ $p+q=5$ and $pq =6$ and $d=4$

solve for $p$ and $q$ to get $a$ and $b$

  • $\begingroup$ "h.c.f." is probably $\gcd$? (greatest common divisor, \gcd) $\endgroup$ – AlexR Feb 11 '15 at 16:32
  • $\begingroup$ @AlexR oh yes, thanks :) $\endgroup$ – Shobhit Feb 11 '15 at 16:37

Let the numbers be $a, b$.

$\gcd(a,b) = \gcd((a+b), lcm(a,b))$ (The reason is explained later)

The $lcm(a,b)$ is given. Thus, you can find the product of the numbers using the formula: $ab=lcm(a,b)*gcd(a,b)$.

$(a+b)$ is also given. Now, you can easily solve these 2 equations.

For this particular question,

$a+b=20$ ----------(1)


$ab=24*4=96$ ----------(2)

Let the numbers be $a,b$ and their $\gcd=d$,

Then $a=pd, b=qd$, where $p,q$ are co-prime.



Now, because $p, q$ are co-primes, $p+q$ and $pq$ will be co-prime too. i.e., $gcd(p+q,pq)=1$. Visit this question for the explanation.

Thus, $\gcd(d(p+q),d(pq))=d$

$\implies$ $\gcd((a+b),lcm(a,b))=d=\gcd(a,b)$

I am not experienced in writing mathematics symbol markdowns. I tried my best. Please edit if required.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.