There were some green and blue pens in a box. If 27 green pens were taken out of the box, there would be 1/3 as many blue pens as green pens. If 40 blue pens were added into the box, there would be 1/2 as many blue as green pens. How many pens were there in the box?
Let us consider that there were x blue pens and y green pens in the box.
Given that if 27 green pens were taken out of the box, there would be 1/3 as many blue pens as green pens. Then we have
x = (y-27)/3
This gives 3x - y = -27..............(1)
Also if 40 blue pens were added into the box, there would be 1/2 as many blue as green pens. Then we have (x+40) = y/2.
This gives 2x - y = -80................(2)
Now subtracting (2) from (1),
we have x = 53
From (1) we have y = 186.
Therefore, there was 53 blue pens and 186 green pens in the box.