//Uses a strong probable prime test with base two
        public static bool IsBaseTwoStrongProbablePrime(long n)
        {
            long s = 0;
            long d = n;

            for (long testS = 0; testS < Math.Log(n, 2); testS++) //O(log(n))
            {
                for (long testD = 1; testD < n; testD += 2)       //O(n) (check to see what limit must be here)
                {
                    if (n - 1 == Math.Pow(2, testS) * testD)      //n = d*2^s + 1
                    {
                        s = testS;
                        d = testD;
                    }
                }
            }

            if (PrimeCalculatorUtilities.PowerModulo(2, d, n) == PrimeCalculatorUtilities.PowerModulo(1, 1, n)) //O(log n)
            {
                return(true);
            }

            for (long r = 0; r < s; r++) //O(s - 1) == O(log(n))
            {
                long power = d * (long)Math.Pow(2, r);
                if (PrimeCalculatorUtilities.PowerModulo(2, power, n) == PrimeCalculatorUtilities.PowerModulo(-1, 1, n))
                {
                    return(true);
                }
            }
            return(false);
        }
        public static long CalculateJacobiSymbol(long a, long b)
        {
            if (b <= 0 || (PrimeCalculatorUtilities.Modulo(b, 2)) == 0)
            {
                return(0);
            }

            long j = 1;

            if (a < 0)
            {
                a = -a;
                if (PrimeCalculatorUtilities.Modulo(b, 4) == 3)
                {
                    j = -j;
                }
            }

            while (a != 0)
            {
                while ((PrimeCalculatorUtilities.Modulo(a, 2) == 0))
                {
                    a = a / 2;
                    if ((PrimeCalculatorUtilities.Modulo(b, 8)) == 3 || (PrimeCalculatorUtilities.Modulo(b, 8)) == 5)
                    {
                        j = -j;
                    }
                }

                long temp = a;
                a = b;
                b = temp;

                if ((PrimeCalculatorUtilities.Modulo(a, 4)) == 3 && (PrimeCalculatorUtilities.Modulo(b, 4)) == 3)
                {
                    j = -j;
                }

                a = PrimeCalculatorUtilities.Modulo(a, b);
            }

            if (b == 1)
            {
                return(j);
            }
            else
            {
                return(0);
            }
        }