I'm self-teaching geometric progressions and was asked to find the sum to $n$ terms of $$x + 1 + \frac{1}{x} + \cdots$$ so I used the formula $$\frac{a(r^n - 1)}{r - 1}$$ with $a = x$ and $r = \frac{1}{x}$, and I arrived at $$\frac{x^{1-n} - x}{x^{-1} - 1}$$ The answer in the book is $$\frac{x^n-1}{x^{n-2}(x - 1)}$$
I cannot see how to manipulate my answer to get to the one in the book (though I know they're equivalent as Wolfram Alpha says so). Hope someone can show me how to approach this?