A poor villager grows mango in his land and sells them in the town. The town is 1000 miles away from the village. He has rented a truck for transporting the mangoes to the town. The truck can carry 1000 mangoes at one time and this season, he was able to yield 3000 mangoes.

There is a problem. At each mile till the town, there is a check post at which he must give one mango each while travelling towards the town. However, if he is travelling from the town towards his village, he wonâ€™t have to give anything.

Tell a way in which the villager can take highest possible number of mangoes to the town.

First of all, he will have to make three trips of 1000 mangoes till 333 miles. After that, he will be left with 2001 mangoes and 667 more miles to go.

Then he must take two trips of 1000 mangoes covering 500 miles more. Doing this, he will be left with 1000 mangoes and 167 remaining miles to reach the town. (He will have to leave a mango behind)

Lastly, he will have to travel the rest of 167 miles with the remaining 1000 mangoes and by the time he reaches town, he will be left with 833 mangoes.