The hotdogs come in packs of 8, while the buns come in packs of 12.
SInce Tom bought the same number of hotdogs as of buns, we need to find what the least number of each is possible.
Notice that with 2 packs of hotdogs, we get 16 of them, with 3 packs of hotdos we get 24 of them.
Now, if we do the same with the packages of buns, with 1 pack we get 12, and with two packs we get 24.
So this is the minimum Tom bought:
3 packs of hotdogs and 2 packages of buns.
Notice that all we have done is find multiples of one and of the other until we found equal number of units for each.
This is the same process as to find the Greatest Common Factor between two numbers.
In our case:
first number: 8 = 2 * 2 * 2
second number: 12 = 2 * 2 * 3
so we collect the largest (greatest) common factors for both:
As far as factors "2" , the greatest is 2 * 2 * 2 (three factors of 2)
and factor 3 (there is only one.
Our Greatest Common factor is therefore: 2 * 2 * 2 * 3 = 24