Four friends stopped to eat at a restaurant. After dinner, they paid their bill and noticed a bowl of candy on the counter.

Megan starts by taking two pieces of candy, but then goes back for more and grabs a seventh of the candy remaining.
Brett took a third of the remaining candy, but returned four because he had a momentary pang of guilt.
Alex then took a fourth of what was left, but returned three for similar reasons.
Evan then took half of the remaining candy, but threw two that looked like they had been slobbered on back into the bowl.
The bowl had only 17 pieces of candy left when the raid was over. How many pieces of candy were originally in the bowl?

Would the answer be 58?

Let x be the number of pieces to start

Megan takes 2 + 1/7 (x-2), leaving x - (2 + (x-2)/7) = (6x-12)/7
Bret took 1/3 * (6x-12)/7 - 4, leaving 2/3 (6x-12)/7 + 4 = (4x+20)/7
Alex took 1/4 (4x+20)/7 - 3, leaving 3/4 (4x+20)/7 + 3 = (3x+36)/7
Evan took 1/2 (3x+36)/7 - 2, leaving 1/2 (3x+36)/7 + 2 = (3x+64)/14
so, now we know that
(3x+64)/14 = 17
solve for x, and check to make sure things work out.

58 is correct.

To find the original number of pieces of candy in the bowl, we need to work backwards from the final count of 17.

Let's start with Evan's actions. We know that he took half of the remaining candy but threw two back into the bowl. So, we can calculate Evan's share as follows:

(17 + 2) * 2 = 38

Now, let's backtrack to Alex's actions. We know that he took a fourth of what was left and returned three. So, we can calculate Alex's share as follows:

(38 + 3) * 4 = 164

Moving on to Brett, we know that he took a third of the remaining candy but returned four. So, we can calculate Brett's share as follows:

(164 + 4) * 3 = 504

Finally, let's consider Megan's actions. We know that she initially took two pieces and then grabbed a seventh of the remaining candy. So, we can calculate Megan's share as follows:

(504 + 2) * 7 = 3570

Therefore, there were originally 3570 pieces of candy in the bowl.