Trial and error. In this case it looks fairly straightforward.
If you're going to have a factor, there's going to be either x+1 or x-1, because x times something needs to make and you've got a at the end. So you know that the first thing you do is try and work out how to make like .
What I would do would be to try and extract and then if that doesn't work by long division.