Question 1035317
He initially had n sheep.

After 1/4 of his sheep was stolen, 3/4 of it remains.  Getting back 3 means he has {{{(3n)/4 + 3}}} remaining.

The second time the robbers came, they stole 1/3 of {{{(3n)/4 + 3}}}, thus {{{(2/3)((3n)/4 + 3)}}} was left.  Having gotten 2 sheep back, the number of remaining sheep is {{{(2/3)((3n)/4 + 3) + 2}}}.

The third time the robbers came, they stole 1/2 of {{{(2/3)((3n)/4 + 3) + 2}}}, thus {{{(1/2)((2/3)((3n)/4 + 3) + 2)}}} was left.  Having gotten 2 sheep back, the number of remaining sheep is {{{(1/2)((2/3)((3n)/4 + 3) + 2)+2}}}.

The last quantity must be equal to n/2.

==> {{{(1/2)((2/3)((3n)/4 + 3) + 2)+2  =n/2}}}

==>{{{(1/3)((3n)/4 + 3) +1 +2 = n/2}}}

==> {{{n/4 + 1 + 3 = n/2}}}

==> {{{4 = n/4}}}  ==> {{{highlight(n = 16)}}}.