Let us solve this by tracking how the toffees are distributed to each child.
Let us say the gentleman initially has x toffees.
The pattern is: Give half of current stock + 1 extra to each child.
First Child:
Gets: 2x+1 toffees
Remaining stock = x−[2x+1]=2x−1
Second Child:
Gets: Half of remaining + 1 = 21(2x−1)+1=4x−21+1=4x+21
Remaining stock = (2x−1)−(4x+21)=4x−23
Third Child:
Gets: 21(4x−23)+1=8x−43+1=8x+41
Remaining stock = (4x−23)−(8x+41)=8x−47
Fourth Child:
Gets: 21(8x−47)+1=16x−87+1=16x+81
Remaining stock = (8x−47)−(16x+81)=16x−815
Fifth Child:
Gets: 21(16x−815)+1=32x−1615+1=32x+161
Notice how each child gets:
Child 1: 2x+1
Child 2: 4x+21
Child 3: 8x+41
Child 4: 16x+81
Child 5: 32x+161
The x-coefficient gets halved each time, and the constant term also gets halved!
Since all toffees are exhausted after 5 children:
(2x+1)+(4x+21)+(8x+41)+(16x+81)+(32x+161)=x
Let us group the x-terms and constant terms:
x-terms: 2x+4x+8x+16x+32x
Constant terms: 1+21+41+81+161
Finding the sum of x-terms:
To add fractions, let us use common denominator 32:
2x=3216x
4x=328x
8x=324x
16x=322x
32x=32x
Sum = 3216x+8x+4x+2x+x=3231x
Finding the sum of constant terms:
Using common denominator 16:
1=1616
21=168
41=164
81=162
161=161
Sum = 1616+8+4+2+1=1631
Our equation becomes:
3231x+1631=x
1631=x−3231x
1631=3232x−31x
1631=32x
Therefore: x=1631×32=31×2=62
The gentleman initially had 62 toffees in his stock.