Solution using symbolic toolbox:
a=sym(5)
b=sym(2)
c=sym(10)
mod(a^b,c)
Another possibility that might help you with big numbers:
a=5
b=2
c=10
ar=mod(a,c)
mod(ar^b,c)
This gives the same result, but might reduce the required range drastically.