there are a whole lot of ways to approach this.
The simplest is just brute force and looking for a pattern. Below is a list of powers of 2 and the power
(1,2), (2,4), (3, 8), (4, 16), (5, 32), (6, 64), (7, 128), (8, 256), (9, 512), (10, 1024)
and in the one's digit we see
2, 4, 8, 6, 2, 4, 8, 6, repeated indefinitely starting at a power of 1.
So if have an array of digits=(2,4, 8, 6)
We first subtract 1 from n and then divide it by 4. We take the remainder and add 1 and use this to index into the digits array.
So in this case we find
\((2015-1) \pmod 4 +1 = 2+1 = 3 \\ digits[3] = 8 \\ \mbox{and so the final digit of }2^{2015}=8\)
.