Alexei and Boris both have a whole number of chocolates, lollipops and toffees, and the product of the number of each boy's of chocolates, lollipops and toffees is 336. It is known that:
(A) Each boy has fewer chocolates than lollipops.
(B) For each boy, the product of the number of chocolates and lollipops equals the total number of candies he has.
(C) Alexei has more lollipops than toffees.
Determine the number of chocolates, lollipops and toffees possessed by each of Alexei and Boris.
(In reply to
re: Computer solution AND 7 AND 48 by Ady TZIDON)
Woops. You're quite right, ADY, my mistake. Maybe I should have had the program find the factors instead of doing it by hand. Here's the revised program -- gives the same result.
Module Module1
Sub main()
Dim chocolates, lollipops, toffees As Integer
Dim factor() As Integer = {1, 2, 3, 4, 6, 7, 8, 12, 14, 16, 21, 24, 28, 42, 48, 56, 84, 112, 168, 336}
For i As Integer = 0 To 18
chocolates = factor(i)
For j As Integer = i + 1 To 19
lollipops = factor(j)
toffees = CInt(336 / chocolates / lollipops)
If chocolates * lollipops = chocolates + lollipops + toffees Then
Console.WriteLine(chocolates & " " & lollipops & " " & toffees)
End If
Next
Next
Console.ReadKey()
End Sub
End Module