Esempio n. 1
0
        private bool IsQuadrupletPrime(PrimesBigInteger value, ref PrimesBigInteger first)
        {
            PrimesBigInteger twin = null;

            if (!value.IsTwinPrime(ref twin))
            {
                return(false);
            }

            PrimesBigInteger twin1 = PrimesBigInteger.Min(value, twin);

            if ((twin1 + 6).IsTwinPrime(ref twin))
            {
                first = twin1;
            }
            else if (twin1 > 6 && (twin1 - 6).IsTwinPrime(ref twin))
            {
                first = twin1 - 6;
            }
            else
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        private void SetTwinPrimes(PrimesBigInteger value)
        {
            PrimesBigInteger twin1 = value.Subtract(PrimesBigInteger.One);
            PrimesBigInteger twin2 = value.Add(PrimesBigInteger.One);
            PrimesBigInteger tmp   = null;

            if (twin1.IsPrime(20) && twin2.IsPrime(20))
            {
                lblTwinPrimes.Text       = string.Format(Distribution.numberline_insidetwinprime, value, twin1, twin2);
                lblTwinPrimes.Visibility = Visibility.Visible;
            }
            else if (value.IsTwinPrime(ref tmp))
            {
                twin1 = PrimesBigInteger.Min(value, tmp);
                twin2 = PrimesBigInteger.Max(value, tmp);
                if (m_ButtonsDict.ContainsKey(twin1))
                {
                    MarkNumber(m_ButtonsDict[twin1]);
                }
                if (m_ButtonsDict.ContainsKey(twin2))
                {
                    MarkNumber(m_ButtonsDict[twin2]);
                }
                lblTwinPrimes.Text       = string.Format(Distribution.numberline_istwinprime, twin1, twin2);
                lblTwinPrimes.Visibility = Visibility.Visible;
            }

            PrimesBigInteger a    = null;
            PrimesBigInteger b    = null;
            string           text = "";

            twin1.PriorTwinPrime(ref a, ref b);
            if (a.CompareTo(twin1) < 0)
            {
                text = string.Format(Distribution.numberline_priortwinprime, a, b) + " ";
            }
            twin1.Add(PrimesBigInteger.One).NextTwinPrime(ref a, ref b);
            text += string.Format(Distribution.numberline_nexttwinprime, a, b);

            lblTwinPrimes2.Text = text;
        }