Getting a matrix to the power of n