Let the total number of pens be x
1st student takes x/3
2nd student also takes x/3
Remaining is (x - x/3 - x/3) = x/3
3rd student takes 1/3rd of this, i.e. x/9
Number of pens taken = x/3 + x/3 + x/9 = 7*x/9
Remaining = x - 7*x/9 = 2*x/9
This is divided evenly amongst the 3, so each gets 2*x/(9*3) = 2*x/27
For this to be a whole number, x has to be a multiple of 27.
The smallest value of x that satisfies this is, of course, 27.
So the smallest number of pens that satisfies the conditions is 27.
Check:
1st person gets 9
2nd student gets 9
Remaining 9
3rd students takes 1/3rd = 3
Total taken = 9 + 9 + 3 = 21
Remaining 6
Divided equally among the 3, each gets 2.
Note: 27 is the *least* number that satisfies the conditions.
Take any multiple of 27, those work for the conditions as well. e.g. 54, 81, 108. So actually this problem has infinite number of solutions.
:)