The determinant is now computed correctly. The problem appears to be that loopindex("x") is in the global scope. In other words, if you recursively call a function with for() loops in it, it will always reference the first time you called a loop of that name. The solution was to uniquely identify the loop with a different name in each iteration.
In this case, instead of calling a for() loop with the tag "i", I called the for loop with the tag "i"&n, where n is the current size of the matrix I am working with. This is unique for each level of the recursion.
See the attached image for the solution.
Ashley, is recursion supposed to work this way? Or am I missing something?