When you are working with the last digits you work mod 10.

When, let n be any arbitary integer.

Thus, (by division algorithm),

N=0,1,2,3,4,5,6,7,8,9 (mod 10).

Meaning, N has to be congruent to exaclty one of those numbers, i.e. that are the possible endings for the integer.

Then, by inspection, we see that, by mod 10,

0^5 = 0

1^5 = 1

2^5 = 2

3^5 = 3

4^5 = 4

5^5 = 5

6^6 = 6

7^5 = 7

8^5 = 8

9^5 = 9

Hence, n^5 is congruent to the same number under mod 10.

Q.E.D.