public static Matrix pow(Matrix A, int exp) { Matrix B = A; for (int i = 1; i < exp; i++) { B = B.times(A); } return B; } I know that the times() method works, but I am getting the wrong answers. I am trying to calculate A^16 where A is a symmetrix, square matrix.