we know that
gate 7 starts with x, ends up with 1
x - ((1/2)x + 1) = 1
x - (1/2)x - 1 = 1
(1/2)x = 2
x = 4
gate 6 starts with x, ends up with 4
x - ((1/2)x + 1) = 4
x - (1/2)x - 1 = 4
(1/2)x = 5
x = 10
gate 5 starts with x, ends up with 10
(1/2)x = 11
x = 22
gate 4 starts with x, ends up with 22
(1/2)x = 23
x = 46
gate 3 starts with x, ends up with 46
(1/2)x = 47
x = 94
gate 2
(1/2)x = 95
x = 190
gate 1
(1/2)x = 191
x = 382
The answer is He started with 382 apples