//Prime test is in p for O:log6(N)
        private static bool IsPrimeByAgrawalKayalSaxena(
            BigInteger n)
        {
            BigInteger X = 0;
            BigInteger r = 0;
            BigInteger a = 0;
            BigInteger b = 0;

            if (a.Pow(b) == n)
            {
                return(false);
            }

            //TODO Find the smallest r such that Or(n) > (log2 n) 2.


            for (a = r; a > 1; a--)
            {
                BigInteger gcd = ToolsMathBigInteger.GetGCDByModulus(a, n);
                if (1 < gcd && gcd < n)
                {
                    return(false);
                }
            }


            if (n <= r)
            {
                return(true);
            }


            BigInteger upper_bound = ToolsMath.Sqrt(EulerPhi(r)) * 1;

            for (a = 0; a < upper_bound; a++)
            {
                if ((X + a).Pow(n) != X.Pow(n) + a * (X.Pow(r) - 1) % n)
                {
                    return(false);
                }
            }
            return(true);
        }
        public static bool IsReverseTruncatablePrime(
            BigInteger current)
        {
            if (!IsPrime(current))
            {
                return(false);
            }
            while (1 < current.ToString().Length)
            {
                current = ToolsMathBigInteger.ReverseDigits(current);
                current = BigInteger.Parse(current.ToString().Substring(1));
                current = ToolsMathBigInteger.ReverseDigits(current);

                if (!IsPrime(current))
                {
                    return(false);
                }
            }
            return(true);
        }