2021 WSMO Team Round/Problem 2

Problem

Bobby has some pencils. When he tries to split them into 5 equal groups, he has 2 left over. When he tries to split them into groups of 8, he has 6 left over. What is the second smallest number of pencils that Bobby could have?

Proposed by pinkpig

Solution

From the problem statement, we have that: $x\equiv2\pmod{5} \\ x\equiv6\pmod{8}$ We can translate this into its parametric form: $x=5n+2=8m+6\implies 8m+4=5n$ Taking both sides $\pmod{5}$, we have a linear congruence $3m\equiv1\pmod{5}$. Since $3*2\equiv6\pmod1\pmod{5}$, $3^{-1}\equiv2\pmod{5}$. Then $m\equiv2\pmod{5}$. We have that $m=5j+2$ from this. Plugging this into the original equation, we get that $x=40j+22$. The smallest possible value of $x$ occurs when $j=0$, so the second smallest occurs when $j=1$, or $x=\boxed{62}$.