Beer and Bottles
The price of a bottle of beer is $3. You can return an empty bottle and get $1 in return. Assuming you have $n (n is a positive integer), calculate the total number of bottles you can drink.
Example: for n = 15 the answer is 7 = 5 + 1 + 1, i.e.
- Buy 5 bottles with the initial amount, i.e. 15 / 3 = 5
- Exchange 5 empty bottles and get $5 back
- Buy 1 bottle, you’ll end up having 1 empty bottle + $2 left from step 2
- Exchange the empty bottle, so now you have 3$
- Buy 1 bottle.