Last Digit of $x^0 + x^1 + x^2 + \cdots + x^{p-1} + x^p$ 
Given $x$ and $p$. Find the last digit of $x^0 + x^1 + x^2 + \cdots + x^{p-1} + x^p$    

I need a general formula. I can find that the sum is equal to
$\dfrac{x^{p+1}-1}{x-1}$
But how to find the last digit. 
P.S: $x\leq 999999$ and $p \leq 10^{15}$ 

Let $s = \sum_{k=0}^{p}x^k$. Calculate $0 \leq a_1, a_2 < 5$, where
$$
a_1 \equiv s \pmod 2 \\
a_2 \equiv s \pmod 5
$$
$a_1$ is easy. If $x \equiv_2 0$, then $a_1 = 1$, else $a_1 \equiv_2 (1+p)$, cause it's $1 + 1^1 + 1^2 + 1^3 + \dots + 1^p$.
$a_2$ isn't harder, $x \equiv_5 0, 1$ are same. For $2, 3, 4$ you can easily observe regularity. Eg.
$$
x \equiv_5 2 \Longrightarrow\\ s \equiv_5
1 + 2^1 + 2^2 + \dots + 2^{p} \equiv_5 \\
1 + 2 + 4 + 8 + \dots + 2^{p} \equiv_5 \\
1 + 2 + 4 + 3 + 1 + 2 \dots + 2^{p} \equiv_5\\
(1 + 2 + 4 + 3) + 1 + 2 \dots + 2^{p} \equiv_5\\
2 \cdot 5 + 1 + 2 \dots + 2^{p}
$$
If you know $a_1, a_2$ you can use Chinese remainder theorem, to calculate number $r \equiv_{10} s$ and it's last digit.
