In a jar, the ratio of the number of yellow balls to the number of purple balls was 1:3. Each time, 5 yellow and 7 purple balls were taken out of the jar. A while later, only 120 purple balls were left in the jar. What was the total number of balls in the jar at first?

yellow : purple = x : 3x

remove 5 yellow and 7 purple k number of times

3x - 7k = 120 , where x and k must be whole numbers
x = (120+7k)/3
clearly 120 + 7k must be a multiple of 3

when k = 1, 120 + 7 is not a multiple of 3
when k = 2, 120 + 14 is not a multiple of 3
when k = 3, 120 + 21 IS a multiple of 3

then x = (120 + 21)/3 = 47

There were 47 yellows and 141 purples for a total of 188 balls at the start.

clearly this is not the only answer.
e.g. suppose k = 9 , (or any multiple of 3)
x = (120 + 63)/3 = 61

so we could have had 61 yellows and 183 purples to start with
and it would still work out.