Problem Link: http://www.spoj.com/problems/LASTDIG/
This is a interesting problem till now in SPOJ(if you follow my previous posts). The problem is to find the last digit in m power n expression. This can be done using https://en.wikipedia.org/wiki/Modular_exponentiation. But I tried to solve in a different method. If you observe any number x, x*x , x*x*x, x*x*x*x and so on, the last digit repeats for every four powers. So we find modulo of the power and 4. And then find pow(a, remainder).