This Question is highly used especially in the first time interviews , used to test your way of thinking and problem solving and Math.
I wrote this simple example to help