Skip to content

Instantly share code, notes, and snippets.

@BelegCuthalion
Last active October 27, 2021 12:41
Show Gist options
  • Save BelegCuthalion/6bbc26f6ae67f5440f8de3a54029fad0 to your computer and use it in GitHub Desktop.
Save BelegCuthalion/6bbc26f6ae67f5440f8de3a54029fad0 to your computer and use it in GitHub Desktop.
def determinant(matrix):
n = len(matrix)
if (n == 1):
return matrix[0][0]
else:
sum = 0
for c in range(n):
sum += ((-1) ** c) * matrix[0][c] * \
determinant([matrix[x][:c]+matrix[x][c+1:] for x in range(1, n)])
return sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment