# Matlab, 33 <s>42</s> bytes Using an anonymous function: @(A)round(inv(A+eps)'*det(A+eps)) Input and output are matrices (2D numeric arrays). `eps` is added in case the matrix is singular. It is "removed" using `round` (the true result is guaranteed to be an integer). Example: >> @(A)round(inv(A+eps)'*det(A+eps)) ans = @(A)round(inv(A+eps)'*det(A+eps)) >> ans([-3,2,-5; -1,0,-2; 3,-4,1]) ans = -8 -5 4 18 12 -6 -4 -1 2 Example with singular matrix: >> @(A)round(inv(A+eps)'*det(A+eps)) ans = @(A)round(inv(A+eps)*det(A+eps)') >> ans([1,0 ; 0,0]) ans = 0 0 0 1 Or [try it online](http://ideone.com/NoIUmO) in Octave.