Pact with the devil

Pact with the devil

To a farmer who lamented how poor he was, the devil appeared and proposed the following:

Look at that bridge, if you pass it in any direction you will have exactly twice the coins you had before passing it. In return, you only have to hand me 24 coins every time you pass the bridge.

The peasant passed the bridge the first time and counted his money, he actually had twice as many coins so he handed 24 over to the devil and crossed the bridge again so he doubled again the money he carried over and handed 24 coins back to the devil .

When the bridge passed for the third time the money doubled, but it turned out that he only had 24 exact coins that he had to give to the devil and he was left with nothing.

How many coins did the farmer have at the beginning?


The farmer had 21 coins.
It is easy to see if we start by the last time you crossed the bridge. At that time I was carrying an amount of money X that by doubling and subtracting 24 it became zero then it is fulfilled:
X * 2-24 = 0 from where we deduce that X = 12

The second time he crossed the bridge, he must have an amount Y such that by multiplying it by two and subtracting 24 it would give us the 12 euros it took the last time it crossed the bridge so we get the following equation:
Y * 2-24 = 12 from where we deduce that Y = 18.

The first time the bridge passed, I had to carry a quantity Z such that multiplying it by 2 and subtracting 24 would give us the 18 coins that he had the second time he passed through the bridge from which we deduce that:
Z * 2-24 = 18 and we get that Z = 21 which is the amount of coins that he carried at the beginning.

Moral, do not accept the deal if the amount you have to deliver each time is greater than what you initially took.