To solve the equation \( x^2 - x - 42 = (x + a)(x - 7) \), we first expand the right-hand side.
Expand the right-hand side: \[ (x + a)(x - 7) = x^2 - 7x + ax - 7a = x^2 + (a - 7)x - 7a \]
Now we can set both sides of the equation equal: \[ x^2 - x - 42 = x^2 + (a - 7)x - 7a \]
We can eliminate \(x^2\) from both sides: \[ -x - 42 = (a - 7)x - 7a \]
Rearranging the equation gives: \[ -x - (a - 7)x = -7a + 42 \] \[ (-1 - (a - 7))x = -7a + 42 \] \[ (-a + 6)x = -7a + 42 \]
For the equation to hold for all \(x\), the coefficients must be equal:
- The coefficient of \(x\) on the left is \( -a + 6 \), and the constant on the right is \( -7a + 42 \).
This gives the following two equations: \[ -a + 6 = 0 \quad \text{(1)} \] \[ -7a + 42 = 0 \quad \text{(2)} \]
Solve equation (1): \[ -a + 6 = 0 \implies a = 6 \]
Now substitute \(a = 6\) into equation (2) to verify: \[ -7(6) + 42 = -42 + 42 = 0 \]
Both equations confirm that \(a = 6\).
Therefore, the value of \(a\) that satisfies the original equation is \( \boxed{6} \).