http://mathworld.wolfram.com/MatrixInverse.html (thanks dave ) explains a method for finding an inverse matrix. Basically for this you'll just have to work it out on paper for a NxN matrix and then write a program to do that.
A method that *might* be easier to implement is:
A(-1) = (1/det A) adj(A)
Where adj(A) =
Where Cnn is the cofactor of Ann
[C11 C12 ... C1n]
[C21 C22 ... C2n]
[... ... ... ...]
[Cn1 Cn2 ... Cnn]
That process requires for total calculations but is pretty simple to implement.