I have to make a recursive function that calculates the determinant of the matrix by 3x3 heres is my code
public int determinant(int matrix[][]) {
if (matrix.length == 2) {
return (matrix[0][0] * matrix[1][1]) - (matrix[0][1] * matrix[1][0]);
}
double sum = 0.0;
for (int i = 0; i < matrix.getNcols(); i++) {
sum += changeSign(i) * matrix.getValueAt(0, i) * determinant(createSubMatrix(matrix, 0, i));
}
return sum;
}
I need to change the last return to make recursive but i dont know how actually.