Maybe there is some faster mathematical way. But this should do it.
public static int LastDigitOfAPowerB(int a, int b)
{
if (b == 0) return 1;
long res = a % 10;
for(int i =1; i<b;++i)
{
res = (res * a) % 10;
}
return (int)res;
}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Maybe there is some faster mathematical way. But this should do it.