Mary baked a number of cookies. She ate one, gave half of the remaining cookies to her sister, ate another one, then gave half of the remaining cookies to her brother. Given that she ended up with #5# cookies, how many did she start with?
1 Answer
Answer:
Explanation:
Work backwards through the story:

Mary ends up with
#5# cookies, after giving away half to her brother. So before she gave away half, she had#10# cookies. 
Before she had
#10# cookies she ate one, so prior to eating that cookie she had#11# cookies. 
Before she gave away half to her sister, she had
#22# cookies. 
Before eating the first cookie she started with
#23# cookies.
We can express the story algebraically.
If Mary starts with
#((n1)/21)/2 = 5#
Multiplying both sides by
#(n1)/21 = 10#
Add one to both sides to get:
#(n1)/2 = 11#
Multiply both sides by
#n1 = 22#
Add one to both sides to get:
#n=23#
Alternative method
In terms of functions, we can define:
#d(x) = x1#
#h(x) = x/2#
Then the inverse functions are:
#d^(1)(x) = x+1#
#h^(1)(x) = 2x#
If
#h(d(h(d(n)))) = 5#
Hence:
#n = d^(1)(h^(1)(d^(1)(h^(1)(5)))) = 2*(2*5+1)+1 = 23#