Answer:
The thief took 36 apples.
Explanation:
This problem can be solved from end to beginning.
The thief ends up with a single apple. This happed after he gave half of the apples he had and two extra apples.
Thus, adding two apples 1+2=3 and doubling the result, the thief had 3*2=6 apples when he met the last guard.
Before that, he gave 2 apples to the second guard, thus he had 6+2=8 apples. Doubling it 8*2=16 is the number of apples he had when met the second guard.
Doing this again, 16+2=18. 18*2=36.
The thief took 36 apples.
Gave 18+2=20 to the first guard. He had 36-20=16 now.
Gave 8+2=10 to the second guard. He had 16-10=6 now.
Gave 3+2=5 to the third guard and got away with just one apple