three brothers try to divide some cookies. The oldest brother gets half of the cookies and half of a cookie. The middle brother gets half of the cookies that are left and half of a cookie. The youngest brother gets half of the cookies that are left and half of a cookie. How many cookies were there in total.... During the process no cookies were cut or broken at any time.

In terms of the original problem:

The city boy loved the farmers daughter.The farmer said city boys were not very smart but he would give his daughter hand if he could do the following: Go up the hill to the apple tree and pick a certain number of apples.
As he came back down the hill he would pass throught three gates.
At each gate he must leave half his apples plus, half an apple.
A whole number of apples must be left at each gate.
How many apples must he pick?

It is not said how many apples he has left when he reaches the bottom, which determines how many he started with.
If after passing through the last gate he has no apples left, he left 1 apple at the last gate, arriving with 1 apple and leaving half his apples, 1/2, plus 1/2 an apple equaling 1 whole apple.
Since he had 1 apple left after leaving the 2nd gate, he must have had (1 1/2)x2 = 3 apples when he arrived at the 2nd gate, leaving half his apples, 1 1/2, plus 1/2 an apple equaling 2 whole apples.
Since he had 3 apple left after leaving the 1st gate, he must have had (3 1/2)x2 = 7 apples when he arrived at the 1st gate, leaving half his apples, 3 1/2, plus 1/2 an apple equaling 4 whole apples.
Thus, if no apples are left after the 3rd gate, he started out with 7 apples.

For any N apples left after leaving the last gate, you would start out with

[[(N + 1/2)2 + 1/2]2 + 1/2]2 = 8N + 7 apples

Starting out with X apples, he has X/2 - 1/2 left after the first gate or (X - 1)/2.
After the second gate he has (X - 1)/4 - 1/2 left or (X - 3)/4.
After third third gate he has (X - 7)/8 left.
If he was to have none left, (X - 7)/8 = 0 and X = 7.
If he was to have 1 apple left, (X - 7)/8 = 1 and X = 15.

Starting with X and ending with N, X = 8N + 7, the same as given you earlier.

To solve this problem, let's work backwards and use a step-by-step approach.

Step 1: Calculating the youngest brother's share
The youngest brother gets half of the cookies that are left and half of a cookie. Let's call the number of cookies left after the middle brother takes his share "x."

So, the youngest brother gets (1/2)x cookies and a half cookie.

Step 2: Calculating the middle brother's share
The middle brother gets half of the cookies that are left and half of a cookie. Since the youngest brother took (1/2)x cookies, the middle brother is left with (x - (1/2)x) = (1/2)x cookies.

The middle brother gets (1/2)(1/2)x = (1/4)x cookies and half of a cookie.

Step 3: Calculating the oldest brother's share
The oldest brother gets half of the cookies and half of a cookie. Since the middle brother took (1/4)x cookies, the oldest brother is left with (1/2 - (1/4))x = (1/4)x cookies.

The oldest brother gets (1/2)(1/4)x = (1/8)x cookies and half of a cookie.

Step 4: Calculating the total number of cookies
Let's add up all the cookies each brother received:

Youngest brother: (1/2)x + (1/2) cookie
Middle brother: (1/4)x + (1/2) cookie
Oldest brother: (1/8)x + (1/2) cookie

To find the total number of cookies, we need to find the value of x that satisfies these equations. But notice that all the fractions of x on the right side of the equations are equal to the number of cookies left, denoted by x. Therefore, we can simplify the equations:

(1/2)x + (1/2) = x
(1/4)x + (1/2) = x
(1/8)x + (1/2) = x

Simplifying further:

(1/2)x = (1/2)
(1/4)x = (1/2)
(1/8)x = (1/2)

Multiplying both sides by their respective denominators:

x = 1 (for (1/2)x = (1/2))
x = 2 (for (1/4)x = (1/2))
x = 4 (for (1/8)x = (1/2))

Since x represents the number of cookies initially, we take the largest value, which is x = 4. Therefore, there were 4 cookies in total.