Rebecca had 4 times as many apples as pears at first. She gave away 16 apples and bought 15 pears. In the end, she had 8 more apples than pears. How many pears did she have at first?

(4x-16)-(1x+15)—-8

3x-31–8
3x=39
13 pears

correct,

your first 2 lines should be
(4x-16)-(1x+15) = 8
3x-31= 8

To solve this problem, let's break it down step by step:

Let's assume that the number of pears Rebecca had at first is "x".
According to the problem, Rebecca had 4 times as many apples as pears at first, so the number of apples she had at first would be 4x.

Then, Rebecca gave away 16 apples, so the number of apples remaining would be 4x - 16.
At the same time, Rebecca bought 15 pears, so the total number of pears would be x + 15.

In the end, Rebecca had 8 more apples than pears, so we can set up the equation:
4x - 16 = x + 15 + 8.

Now let's solve the equation step by step:

4x - 16 = x + 23
Subtracting x from both sides:
3x - 16 = 23
Adding 16 to both sides:
3x = 39
Dividing both sides by 3:
x = 13.

Therefore, Rebecca had 13 pears at first.