A box contains many candies.
If 3 candies are taken away, the rest can be shared evenly among 7 people.
If 5 are taken away, the rest can be shared evenly among 8 people.
If 3 candies are added, then the box can be shared evenly among 5 people.
What is the smallest number of candies in the box?
N - 3 = 7a ⇒ N = 7a + 3
N - 5 = 8b ⇒ N = 8b + 5
N + 3 = 5c ⇒ N = 5c - 3
7a + 3 = 5c - 3
5c - 7a = 6 ⇒ c = ( 7a + 6) / 5
5c - 3 = 8b + 5
5c - 8b = 8 ⇒ c = ( 8b+ 8) / 5
7a + 6 = 8b + 8
7a - 8b = 2
a b N
6 5 not possible
14 12 not possible
22 19 157
Smallest number of candies in the box = 157