Wrote prime determinant function