0

```
I need to solve a 3x3 matrix, x,y,z of a funtion (I only have a 2x2 matrix determinant solved)
I have figured out how to solve the determinant with this code and I have created another attached program that displays any size matrix
I thought it might help.
```

```
public class matrix1 {
public int determinant(int[][] arr) {
int result = 0;
if (arr.length == 1) {
result = arr[0][0];
return result;
}
if (arr.length == 2) {
result = arr[0][0] * arr[1][1] - arr[0][1] * arr[1][0];
return result;
}
for (int i = 0; i < arr[0].length; i++) {
int temp[][] = new int[arr.length - 1][arr[0].length - 1];
for (int c = 1; c < arr.length; c++) {
for (int a = 0; a < arr[0].length; a++) {
if (a < i) {
temp[c - 1][a] = arr[c][a];
} else if (a > i) {
temp[c - 1][a - 1] = arr[c][a];
}
}
}
result += arr[0][i] * Math.pow(-1, (int) i) * determinant(temp);
}
return result;
}
}
```

```
public class matrix1app {
public static void main(String[] args) {
int array[][] = { { 2, 3 }, { 6, 4 } };
matrix1 d = new matrix1();
int result = d.determinant(array);
System.out.println(result);
}
}
```