private string piStellen(int n)
        {
            if (n < 0) { n = 0; }
            if (n > 999999) { n = 20000; }

            int[] faktor = { 0, 4, 0, 0, -2, -1, -1 };
             

            double ergA = 0, ergB = 0, ergC = 0 ;
            for (int i=0;i < n;i++)
            {
                double erg = 0;
                 
                for (int k=1;k <= 6;k++)
                {
                    if (k == 2) k = 4;
                    int m = 8 * i + k;
                    double powWert = Xpow16hN_modM(n - i, m);
                    double teilerg = faktor[k]*powWert / (1.0 * m);
                    erg = erg + teilerg;
                }
                ergA = ergA + erg;

            }
            ergA = ergA - (int)ergA;
            if (ergA < 0) ergA = ergA + 1;


            for (int i = n; i < n+11; i++)
            {
                double erg = 0;
                for (int k = 1; k <= 6; k++)
                {
                    if (k == 2) k = 4;
                    int m = 8 * i + k;
                    double powWert = Math.Pow(16, n - i); // , m, 0);
                    double teilerg = faktor[k] * powWert / (1.0 * m);
                    erg = erg + teilerg;
                }
                ergB = ergB + erg;
            }

            ergC = ergA + ergB;
            if (ergC < 0) ergC = ergC + 1;
            string hexWert = XHexString(ergC, 15, true);

            return hexWert;
        }


        private double Xpow16hN_modM(int n, int m) // (16 hoch n) mod m ... 16^n mod m
        {
            double p = 1;

            if (n > 1)
            {
                double r = Xpow16hN_modM(n / 2, m);
                if (n % 2 == 0) { p = (r * r) % m; }
                else { p = (16 * r * r) % m; }
            }
            else
            {
                if (n == 0) p = 1;
                else p = 16 % m;
            }
            return p;
        }


        private string XHexString(double x, int stellenzahl, bool trennung)
          // die Dezimalzahl x muss eine Kommazahl sein und darf max. 1 Ziffer vor dem Komma haben (ohne Kontrolle!)
        {
            string hexChars = "0123456789ABCDEF";
            string sb = "";
            double y = Math.Abs(x);
            if (y > 1) { sb = hexChars[(int)y] + ","; y = y - (int)y; }
            for (int i = 1; i <= stellenzahl; i++)
            {
                y = 16d * (y - Math.Floor(y));
                sb = sb + hexChars[(int)y];
                if (trennung) if (i % 5 == 0) sb = sb + " ";
            }

            return sb;
        }