public class tdet1 { static final int N = 4; static final double[][] A = { { 1, 4,-3, 1}, { 2, 0, 6, 3}, { 4,-1, 2, 5}, { 1, 0,-2, 4} }; public static void main( String[] args ){ System.out.println(det(N,A));} static double det( int n, double[][] a ){ if ( n <= 1 ) return a[0][0]; double[][] aa = new double[n-1][n-1]; double sum = 0.0; double sign = -1.0; for (int i=0; i<n; i++){ for (int j=1; j<n; j++){ for (int k=0; k<n; k++){ if ( k < i ) aa[j-1][k ] = a[j][k]; else { if ( k > i ) aa[j-1][k-1] = a[j][k]; }}} sign = -sign; sum += a[0][i] * sign * det(n-1, aa); /* recursive call */} return sum;}}