private string WriteOptimizedNDet(int n, int[] xRange, int[] yRange)
        {
            var stringBuilder = new StringBuilder();
            var chacheSets    = GetCacheSets(n);
            var cacheVar      = CreateCacheVarName(xRange, yRange);

            if (!chacheSets.ContainsKey(cacheVar))
            {
                if (n > 2)
                {
                    bool plus = true;
                    for (int i = 0; i < n; i++)
                    {
                        if (i > 0)
                        {
                            stringBuilder.Append(plus ? " + " : " - ");
                        }

                        int x = xRange[i];
                        int y = yRange[0];
                        stringBuilder.Append(Formatter.SourceMatrixElement(MatrixSize, y, x));
                        plus = !plus;

                        stringBuilder.Append(" * ");
                        stringBuilder.Append(WriteOptimizedNDet(n - 1, xRange.Where(j => j != x).ToArray(), yRange.Where(j => j != y).ToArray()));
                    }
                }
                else
                {
                    stringBuilder.AppendFormat(Formatter.CacheContent(Formatter.SourceMatrixElement(MatrixSize, yRange[0], xRange[0]), Formatter.SourceMatrixElement(MatrixSize, yRange[1], xRange[1]), Formatter.SourceMatrixElement(MatrixSize, yRange[0], xRange[1]), Formatter.SourceMatrixElement(MatrixSize, yRange[1], xRange[0])));
                }

                chacheSets[cacheVar] = Formatter.CacheMember(cacheVar, stringBuilder.ToString());
                stringBuilder.Clear();
            }

            return(cacheVar);
        }