Juca has fewer than 800 marbles. He likes to separate the marbles into groups with the same number of marbles. He noticed that if he forms groups of 3 marbles each, exactly 2 marbles are left over. If he forms groups of 4 marbles, 3 marbles are left over. If he forms groups of 5 marbles, 4 marbles are left over. Finally, if he forms groups of 7 marbles each, 6 marbles are left over.

(a) If Juca formed groups of 20 marbles each, how many marbles would be left over?

(b) How many marbles does Juca have?
Solution

(a) Let $B$ be the number of marbles Juca has. Note that the number of marbles left over when forming a group is equal to the remainder of the division of $B$ by the size of the groups. To determine the remainder in the division by 20, one should use the remainders in the division by 4 and by 5, since $20=4 \cdot 5$. Suppose one more marble is given to Juca. Knowing that with groups of 5 marbles, 4 marbles are left over, and with groups of 4, 3 are left over, then Juca can divide the $B+1$ marbles into groups of 4 marbles and groups of 5 marbles without any leftovers, so $B+1$ is a multiple of $4 \cdot 5=20$, since this is the Least Common Multiple between 4 and 5. Therefore, $B$ leaves a remainder of 19 when divided by 20. Thus, 19 marbles would be left over.
(b) For each of the numbers in the set $\{3,4,5,7\}$, the remainder in the division is one unit less than the size of the groups. Thus, if we add one more marble to Juca's collection, we will have a number $B+1$ that is a multiple of 3, 4, 5, and 7, consequently, $B+1$ is a multiple of the Least Common Multiple of these four numbers, that is, a multiple of $3 \cdot 4 \cdot 5 \cdot 7=420$. Since Juca has fewer than 800 marbles, then $B+1=420$ and thus we conclude that $B=419$.