Let's break this down step by step.
First, we know the product of the three children's ages is 36. The factors of 36 that are possible ages for the children (assuming whole years and not considering the possibility of twins or triplets with the same age) are:
1, 1, 36
1, 2, 18
1, 3, 12
1, 4, 9
1, 6, 6
2, 2, 9
2, 3, 6
3, 3, 4
Next, the second man can't determine the children's ages based on the product alone. This implies that there must be at least two sets of factors with the same sum because if there was only one, he would know their ages.
Then, the first man provides another clue: the sum of his children's ages equals the number on the bus the second man can see. The second man looks at the bus and still can't determine the children's ages, which means that there are at least two different sets of factors with the same sum.
Let's examine the sums of the possible factors:
1 + 1 + 36 = 38
1 + 2 + 18 = 21
1 + 3 + 12 = 16
1 + 4 + 9 = 14
1 + 6 + 6 = 13
2 + 2 + 9 = 13
2 + 3 + 6 = 11
3 + 3 + 4 = 10
Looking at the sums, we can see that there are two sets of factors that add up to the same sum of 13: (1, 6, 6) and (2, 2, 9). Since the second man still couldn't determine the children's ages based on the bus number, it must be because the number on the bus was 13, and there are two possible combinations that sum up to 13.
Finally, the first man mentions that his eldest child has a name, which implies there is a single oldest child. This eliminates the (1, 6, 6) combination because it would mean there are two eldest children (twins) of the same age. Therefore, the only possible combination left is (2, 2, 9), as it has a distinct eldest child.
So the ages of the children are:
X = 2
Y = 2
Z = 9