public static int determinant(int[][] matrix){
		//preconditions
		if(matrix == null)throw new IllegalArgumentException("matrix must not be null");
		for(int i = 0; i < matrix.length; i++){
			if(matrix.length != matrix[i].length)throw new IllegalArgumentException("matrix must be square!");
		}
		
		if(matrix.length == 2){
			return matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0];
		}
		
		int sign = 1;
		int total = 0;
		for(int i = 0; i < matrix[0].length; i++){
			total += sign * matrix[0][i] * determinant(removeRowAndCol(matrix, 0, i));
			sign*= -1;
		}
		
		return total;
	}