示例#1
0
        protected override void DoExecute()
        {
            FireOnStart();

            try
            {
                PrimesBigInteger modulus = m_SecondParameter;

                PrimesBigInteger from = m_From;

                while (from.CompareTo(m_To) <= 0)
                {
                    string msg;
                    try
                    {
                        PrimesBigInteger result = from.ModInverse(modulus);
                        msg = result.ToString("D");
                    }
                    catch (Exception ex)
                    {
                        msg = "-";
                    }
                    FireOnMessage(this, from, msg);
                    from = from.Add(PrimesBigInteger.One);
                }
            }
            catch (Exception ex)
            {
            }

            FireOnStop();
        }
示例#2
0
        private void ExecuteSystematicThread()
        {
            FireEventExecuteTest();

            bool foundwitness = false;

            int rounds = 0;

            while (m_SystematicBaseFrom <= m_SystematicBaseTo)
            {
                rounds++;
                if (ExecuteWitness(rounds, m_SystematicBaseFrom))
                {
                    foundwitness = true; break;
                }
                m_SystematicBaseFrom = m_SystematicBaseFrom + 1;
            }

            if (foundwitness)
            {
                log.Info(string.Format((rounds == 1) ? rsc.Primetest.mr_witnessfound1 : rsc.Primetest.mr_witnessfound2, rounds, m_Value));
            }
            else
            {
                log.Info(string.Format((rounds == 1) ? rsc.Primetest.mr_witnessnotfound1 : rsc.Primetest.mr_witnessnotfound2, rounds, m_Value));
            }

            FireEventCancelTest();
        }
示例#3
0
 void iscBaseRandom_Execute(PrimesBigInteger value)
 {
     if (ForceGetInteger != null)
     {
         ForceGetInteger(new ExecuteIntegerDelegate(Execute));
     }
 }
示例#4
0
 void iscMod_KeyDown(PrimesBigInteger value)
 {
     if (value != null)
     {
         this.Mod = value;
     }
 }
示例#5
0
        public NumberRectangleControl()
        {
            InitializeComponent();
            Rows      = 10;
            Columns   = 10;
            m_Buttons = new ArrayList();
            InputValidator <PrimesBigInteger> ivHeight = new InputValidator <PrimesBigInteger>();

            ivHeight.Validator = new BigIntegerMinValueMaxValueValidator(null, PrimesBigInteger.ValueOf(10), PrimesBigInteger.ValueOf(500));
            iscHeight.AddInputValidator(InputSingleControl.Free, ivHeight);
            iscHeight.Execute     += new ExecuteSingleDelegate(isc_Execute);
            iscHeight.OnInfoError += new MessageDelegate(iscHeight_OnInfoError);
            iscHeight.KeyDown     += new ExecuteSingleDelegate(iscWidth_KeyDown);

            InputValidator <PrimesBigInteger> ivWidth = new InputValidator <PrimesBigInteger>();

            ivWidth.Validator = new BigIntegerMinValueMaxValueValidator(null, PrimesBigInteger.ValueOf(10), PrimesBigInteger.ValueOf(500));
            iscWidth.AddInputValidator(InputSingleControl.Free, ivWidth);
            iscWidth.Execute     += new ExecuteSingleDelegate(isc_Execute);
            iscWidth.OnInfoError += new MessageDelegate(iscHeight_OnInfoError);
            iscWidth.KeyDown     += new ExecuteSingleDelegate(iscWidth_KeyDown);

            InputValidator <PrimesBigInteger> ivStart = new InputValidator <PrimesBigInteger>();

            ivStart.Validator = new BigIntegerMinValueValidator(null, PrimesBigInteger.ValueOf(1));
            iscStart.AddInputValidator(InputSingleControl.Free, ivStart);
            iscStart.Execute     += new ExecuteSingleDelegate(isc_Execute);
            iscStart.OnInfoError += new MessageDelegate(iscHeight_OnInfoError);
            iscStart.KeyDown     += new ExecuteSingleDelegate(iscWidth_KeyDown);

            this.OnDrawStart += new VoidDelegate(NumberRectangleControl_OnDrawStart);
            this.OnDrawStop  += new VoidDelegate(NumberRectangleControl_OnDrawStop);

            m_start = PrimesBigInteger.One;
        }
示例#6
0
        public PrimesBigInteger ValidateInput(TextBox tbSource)
        {
            PrimesBigInteger result = PrimesBigInteger.Zero;
            InputValidator <PrimesBigInteger> m_Validator;

            if (m_Validators.ContainsKey(tbSource.Tag.ToString()))
            {
                m_Validator = m_Validators[tbSource.Tag.ToString()];
            }
            else
            {
                m_Validator           = new InputValidator <PrimesBigInteger>();
                m_Validator.Validator = new BigIntegerValidator(tbSource.Text);
            }

            try
            {
                TextBoxValidator <PrimesBigInteger> tbvalidator = new TextBoxValidator <PrimesBigInteger>(m_Validator.Validator, tbSource, m_Validator.DefaultValue);
                tbvalidator.Validate(ref result);
            }
            catch (ControlValidationException cvex)
            {
                cvex.HelpAction = m_Validator.LinkOnlinehelp;
                throw cvex;
            }

            return(result);
        }
示例#7
0
        /// <summary>
        /// Calculates unary expressions and pushes the result into the operands stack
        /// </summary>
        /// <param name="op">Unary operator</param>
        /// <param name="operand">Operand</param>
        private void Calculate(string op, PrimesBigInteger operand)
        {
            PrimesBigInteger res = PrimesBigInteger.One;

            try
            {
                switch (op)
                {
                case Token.UnaryMinus: res = operand.Multiply(PrimesBigInteger.NegativeOne); break;

                //case Token.Abs:        res = Math.Abs(operand); break;
                //case Token.ACosine:    res = Math.Acos(operand); break;
                //case Token.ASine:      res = Math.Asin(operand); break;
                //case Token.ATangent:   res = Math.Atan(operand); break;
                //case Token.Cosine:     res = Math.Cos(operand); break;
                //case Token.Ln:         res = Math.Log(operand); break;
                //case Token.Log10:      res = Math.Log10(operand); break;
                //case Token.Sine:       res = Math.Sin(operand); break;
                case Token.Sqrt: res = operand.SquareRoot(); break;
                    //case Token.Tangent:    res = Math.Tan(operand); break;
                    //case Token.Exp:        res = Math.Exp(operand); break;
                    //case Token.Factorial:  for (int i = 2; i <= (int)operand; res *= i++) ;
                    //break;
                }

                operands.Push(PostProcess(res));
            }
            catch (Exception e)
            {
                ThrowException(e.Message);
            }
        }
示例#8
0
 protected void FireOnMessage(INTFunction function, PrimesBigInteger value, string message)
 {
     if (Message != null)
     {
         Message(function, value, message);
     }
 }
示例#9
0
        private PrimesBigInteger CalculateFactor(PrimesBigInteger value)
        {
            PrimesBigInteger x = m_StartFX;
            PrimesBigInteger y = m_StartFX;
            PrimesBigInteger d = PrimesBigInteger.One;
            PrimesBigInteger a = m_A;
            int i = 0;

            if (value.Mod(PrimesBigInteger.Two).Equals(PrimesBigInteger.Zero))
            {
                return(PrimesBigInteger.Two);
            }
            do
            {
                x = x.ModPow(PrimesBigInteger.Two, value).Add(a).Mod(value);
                y = y.ModPow(PrimesBigInteger.Two, value).Add(a).Mod(value);
                y = y.ModPow(PrimesBigInteger.Two, value).Add(a).Mod(value);
                d = PrimesBigInteger.GCD(x.Subtract(y), value);
                i++;
                if (y.Equals(x))
                {
                    log.Info("Change Values");
                    a = PrimesBigInteger.ValueOf(new Random().Next());
                    x = y = PrimesBigInteger.ValueOf(new Random().Next());
                    i = 0;
                }
            }while (d.Equals(PrimesBigInteger.One));
            return(d);
        }
        private void btnGeneratePolynom_Click(object sender, RoutedEventArgs e)
        {
            IPolynom p = null;

            if (sender == btnGenerateSecondDegree)
            {
                p = new SecondDegreePolynom();
                p.SetParameter("a", PrimesBigInteger.ValueOf(3));
                p.SetParameter("b", PrimesBigInteger.ValueOf(7));
                p.SetParameter("c", PrimesBigInteger.ValueOf(13));
                m_InputControlPolynom.SetText(InputRangeControl.FreeFrom, "0");
                m_InputControlPolynom.SetText(InputRangeControl.FreeTo, "49");

                m_InputControlPolynom.SetText(InputRangeControl.CalcFromFactor, "0");
                m_InputControlPolynom.SetText(InputRangeControl.CalcFromBase, "2");
                m_InputControlPolynom.SetText(InputRangeControl.CalcFromExp, "3");
                m_InputControlPolynom.SetText(InputRangeControl.CalcFromSum, "-1");
                m_InputControlPolynom.SetText(InputRangeControl.CalcToFactor, "1");
                m_InputControlPolynom.SetText(InputRangeControl.CalcToBase, "7");
                m_InputControlPolynom.SetText(InputRangeControl.CalcToExp, "2");
                m_InputControlPolynom.SetText(InputRangeControl.CalcToSum, "0");
            }
            else if (sender == btnGeneratePrimesEuler)
            {
                p = new EulerPolynom();
                m_InputControlPolynom.SetText(InputRangeControl.FreeFrom, "0");
                m_InputControlPolynom.SetText(InputRangeControl.FreeTo, "39");
            }
            if (p != null)
            {
                m_InputControlPolynom.Polynom = p;
                SetInputControl(m_InputControlPolynom);
            }
        }
示例#11
0
        private void ExecuteRandom(IList <KeyValuePair <string, Range> > parameters)
        {
            PrimesBigInteger numberOfCalculations = icNumberOfCalculations.GetValue();
            PrimesBigInteger numberOfFormulars    = icNumberOfFormulars.GetValue();
            PrimesBigInteger xfrom = null;
            PrimesBigInteger xto   = null;

            ircRandomChooseXRange.GetValue(ref xfrom, ref xto);

            if (numberOfFormulars != null)
            {
                if (rbChooseRange.IsChecked.Value)
                {
                    if (xfrom != null && xto != null)
                    {
                        numberOfCalculations = PrimesBigInteger.NaN;
                        Execute(m_Polynom, xfrom, xto, numberOfCalculations, numberOfFormulars, parameters);
                    }
                }
                else if (rbChooseRandom.IsChecked.Value)
                {
                    if (numberOfCalculations != null)
                    {
                        xfrom = PrimesBigInteger.NaN;
                        xto   = PrimesBigInteger.NaN;

                        Execute(m_Polynom, xfrom, xto, numberOfCalculations, numberOfFormulars, parameters);
                    }
                }
            }
        }
 private void Generate10Times_Click(object sender, RoutedEventArgs e)
 {
     log.Columns = 1;
     if (sender != null && sender.GetType() == typeof(Button))
     {
         PrimesBigInteger digits = null;
         if (sender == btnGeneratePrimes10Times20)
         {
             digits = PrimesBigInteger.ValueOf(20);
         }
         else if (sender == btnGeneratePrimes10Times50)
         {
             digits = PrimesBigInteger.ValueOf(50);
         }
         else if (sender == btnGeneratePrimes10Times100)
         {
             digits = PrimesBigInteger.ValueOf(100);
         }
         else if (sender == btnGeneratePrimesNTimesM)
         {
             SetInputControl(m_InputControlNTimesM);
         }
         if (digits != null)
         {
             ExecuteGenerate10Primes(digits);
         }
     }
 }
示例#13
0
 public CountPiXThread(FunctionPiX functionPiX, Dispatcher dispatcher, ObjectParameterDelegate objdelegate, PrimesBigInteger to)
 {
     this.m_FunctionPiX = functionPiX;
     this.m_Dispatcher  = dispatcher;
     m_objdelegate      = objdelegate;
     m_To = to;
 }
示例#14
0
        public void Execute(PrimesBigInteger value)
        {
            m_Value  = value.LongValue;
            m_Data.N = m_Value;

            StartThread();
        }
示例#15
0
        protected override void DoExecute()
        {
            FireOnStart();

            PrimesBigInteger from = m_From;

            while (from.CompareTo(m_To) <= 0)
            {
                StringBuilder    sbMessage = new StringBuilder("[");
                PrimesBigInteger d         = PrimesBigInteger.One;
                while (d.CompareTo(from) < 0)
                {
                    if (PrimesBigInteger.GCD(d, from).Equals(PrimesBigInteger.One))
                    {
                        if (sbMessage.Length > 1)
                        {
                            sbMessage.Append(", ");
                        }
                        sbMessage.Append(d.ToString());
                        FireOnMessage(this, from, sbMessage.ToString());
                    }
                    d = d.Add(PrimesBigInteger.One);
                }
                sbMessage.Append("]");
                FireOnMessage(this, from, sbMessage.ToString());

                from = from.Add(PrimesBigInteger.One);
            }

            FireOnStop();
        }
示例#16
0
        public void MarkNumber(PrimesBigInteger number, Brush color)
        {
            try
            {
                if (!m_MarkedNumbers.ContainsKey(number))
                {
                    m_MarkedNumbers.Add(number, color);
                }
                else
                {
                    m_MarkedNumbers[number] = color;
                }

                UIElementCollection buttons =
                    ControlHandler.GetPropertyValue(numbergrid, "Children") as UIElementCollection;
                int i = (int)ControlHandler.GetPropertyValue(buttons, "Count");

                NumberButton first = (buttons[Columns + Rows - 2] as NumberButton);
                if (first.BINumber.Add(number).CompareTo(PrimesBigInteger.ValueOf(Columns * Rows)) < 0)
                {
                    int          index = number.Subtract(first.BINumber).IntValue + Columns + Rows - 2;
                    NumberButton btn   = buttons[index] as NumberButton;
                    ControlHandler.SetPropertyValue(btn, "Background", color);
                }
            }
            catch (Exception e)
            {
            }
        }
示例#17
0
 public void FireOnActualDivisorChanged(PrimesBigInteger i)
 {
     if (OnActualDivisorChanged != null)
     {
         OnActualDivisorChanged(i);
     }
 }
示例#18
0
        private PrimesBigInteger GetPrimesCount()
        {
            PrimesBigInteger result = PrimesBigInteger.One;

            try
            {
                IValidator <PrimesBigInteger>       validator   = new BigIntegerMinValueValidator(tbN.Text, PrimesBigInteger.ValueOf(1));
                TextBoxValidator <PrimesBigInteger> tbValidator = new TextBoxValidator <PrimesBigInteger>(validator, tbN, "1");
                tbValidator.Validate(ref result);
            }
            catch (ControlValidationException cvex)
            {
                switch (cvex.ValidationResult)
                {
                case Primes.WpfControls.Validation.ValidationResult.WARNING:
                    Info(cvex.Message, cvex.Control as TextBox);
                    break;

                case Primes.WpfControls.Validation.ValidationResult.ERROR:
                    Error(cvex.Message, cvex.Control as TextBox);
                    break;
                }
            }

            return(result);
        }
示例#19
0
        /// <summary>
        /// Calculates binary expressions and pushes the result into the operands stack
        /// </summary>
        /// <param name="op">Binary operator</param>
        /// <param name="operand1">First operand</param>
        /// <param name="operand2">Second operand</param>
        private void Calculate(string op, PrimesBigInteger operand1, PrimesBigInteger operand2)
        {
            PrimesBigInteger res = PrimesBigInteger.Zero;

            try
            {
                switch (op)
                {
                case Token.Add: res = operand1.Add(operand2); break;

                case Token.Subtract: res = operand1.Subtract(operand2); break;

                case Token.Multiply: res = operand1.Multiply(operand2); break;

                case Token.Divide: res = operand1.Divide(operand2); break;

                case Token.Mod: res = operand1.Mod(operand2); break;

                case Token.Power: res = operand1.Pow(operand2.IntValue); break;

                case Token.Log: res = PrimesBigInteger.Zero; break;

                case Token.Root: res = PrimesBigInteger.Zero; break;
                }

                operands.Push(PostProcess(res));
            }
            catch (Exception e)
            {
                ThrowException(e.Message);
            }
        }
示例#20
0
        void ircGoldbach_Execute(PrimesBigInteger from, PrimesBigInteger to, PrimesBigInteger second)
        {
            m_From = from;
            m_To   = to;

            StartThread();
        }
示例#21
0
 private void FireRowMouseOverEvent(int value)
 {
     if (RowMouseOver != null)
     {
         RowMouseOver(PrimesBigInteger.ValueOf(value).Divide(PrimesBigInteger.Two));
     }
 }
示例#22
0
        private void DrawNumberButton(PrimesBigInteger value, double x, double y)
        {
            Ellipse nb = ControlHandler.CreateObject(typeof(Ellipse)) as Ellipse;

            //NumberButton nb = ControlHandler.CreateObject(typeof(NumberButton)) as NumberButton;
            //ControlHandler.SetPropertyValue(nb, "NumberButtonStyle", NumberButtonStyle.Ellipse.ToString());
            //ControlHandler.SetPropertyValue(nb, "BINumber", value);
            ControlHandler.SetPropertyValue(nb, "Width", 6);
            ControlHandler.SetPropertyValue(nb, "Height", 6);
            ToolTip tt = ControlHandler.CreateObject(typeof(ToolTip)) as ToolTip;

            ControlHandler.SetPropertyValue(tt, "Content", value.ToString());
            ControlHandler.SetPropertyValue(nb, "ToolTip", tt);

            //if (value.IsPrime(10))
            //  ControlHandler.SetPropertyValue(nb, "Background", Brushes.Blue);
            //else
            //  ControlHandler.SetPropertyValue(nb, "Background", Brushes.Gray);
            if (value.IsPrime(10))
            {
                ControlHandler.SetPropertyValue(nb, "Fill", Brushes.Blue);
            }
            else
            {
                ControlHandler.SetPropertyValue(nb, "Fill", Brushes.Gray);
            }

            ControlHandler.ExecuteMethod(PaintArea, "SetTop", new object[] { nb, y - 3 });
            ControlHandler.ExecuteMethod(PaintArea, "SetLeft", new object[] { nb, x - 3 });
            ControlHandler.AddChild(nb, PaintArea);
        }
示例#23
0
        //private ArrowLine GetLine(ArrowLine l)
        //{
        //    foreach (ArrowLine line in m_Arrows)
        //    {
        //        double srcx1 = (double)ControlHandler.GetPropertyValue(line, "X1");
        //        double srcx2 = (double)ControlHandler.GetPropertyValue(line, "X2");
        //        double srcy1 = (double)ControlHandler.GetPropertyValue(line, "Y1");
        //        double srcy2 = (double)ControlHandler.GetPropertyValue(line, "Y2");
        //        double destx1 = (double)ControlHandler.GetPropertyValue(l, "X1");
        //        double destx2 = (double)ControlHandler.GetPropertyValue(l, "X2");
        //        double desty1 = (double)ControlHandler.GetPropertyValue(l, "Y1");
        //        double desty2 = (double)ControlHandler.GetPropertyValue(l, "Y2");

        //        if (srcx1 == destx1 && srcx2 == destx2 && srcy1 == desty1 && srcy2 == desty2) return line;
        //    }
        //    return null;
        //}

        //private bool ContainsLine(ArrowLine l)
        //{
        //    return GetLine(l) != null;
        //}

        //public void AddCircle(PrimesBigInteger counter, double x, double y)
        //{
        //    Polyline p = ControlHandler.CreateObject(typeof(Polyline)) as Polyline;
        //    ControlHandler.SetPropertyValue(p, "Stroke", Brushes.Black);
        //    ControlHandler.SetPropertyValue(p, "StrokeThickness", 1.5);
        //    PointCollection pc = ControlHandler.GetPropertyValue(p, "Points") as PointCollection;
        //    int c = 16;
        //    double radius = 25;
        //    for (int value = 0; value <= c; value++)
        //    {
        //        double angle = (360.0 / (double)c) * value;
        //        double top = radius / 2 + (Math.Sin((angle * 2 * Math.PI) / 360.0) * radius / 2);
        //        double left = radius / 2 + (Math.Cos((angle * 2 * Math.PI) / 360.0) * radius / 2);
        //        ControlHandler.ExecuteMethod(pc, "Add", new object[] { new Point(top, left) });
        //    }
        //    if (!ContainsCircle(x, y))
        //    {
        //        m_Circles.Add(p);
        //        m_CirclesMark.Add(counter, p);
        //        ControlHandler.ExecuteMethod(ArrowArea, "SetLeft", new object[] { p, x });
        //        ControlHandler.ExecuteMethod(ArrowArea, "SetTop", new object[] { p, y });
        //        ControlHandler.AddChild(p, ArrowArea);
        //    }
        //    else
        //    {
        //        ResetCircle(counter, x, y);
        //    }
        //}

        public void AddCircle(PrimesBigInteger counter, Ellipse source)
        {
            Polyline p = ControlHandler.CreateObject(typeof(Polyline)) as Polyline;

            ControlHandler.SetPropertyValue(p, "Stroke", Brushes.Black);
            ControlHandler.SetPropertyValue(p, "StrokeThickness", 1.5);
            PointCollection pc     = ControlHandler.GetPropertyValue(p, "Points") as PointCollection;
            int             c      = 16;
            double          radius = 25;
            double          x      = (double)ControlHandler.ExecuteMethod(PaintArea, "GetLeft", source);
            double          y      = (double)ControlHandler.ExecuteMethod(PaintArea, "GetTop", source);

            for (int value = 0; value <= c; value++)
            {
                double angle = (360.0 / (double)c) * value;
                double top   = radius / 2 + (Math.Sin((angle * 2 * Math.PI) / 360.0) * radius / 2);
                double left  = radius / 2 + (Math.Cos((angle * 2 * Math.PI) / 360.0) * radius / 2);
                ControlHandler.ExecuteMethod(pc, "Add", new object[] { new Point(top, left) });
            }
            if (!m_CirclesSource.ContainsKey(source))
            {
                m_CirclesSource.Add(source, p);
                m_CirclesMark.Add(counter, p);
                ControlHandler.ExecuteMethod(ArrowArea, "SetLeft", new object[] { p, x });
                ControlHandler.ExecuteMethod(ArrowArea, "SetTop", new object[] { p, y });
                ControlHandler.AddChild(p, ArrowArea);
            }
            else
            {
                p = m_CirclesSource[source];
                ResetCircle(counter, p);
            }
        }
示例#24
0
        protected override void DoExecute()
        {
            FireOnStart();

            PrimesBigInteger from = m_From;

            while (from.CompareTo(m_To) <= 0)
            {
                if (from.IsPrime(20))
                {
                    FireOnMessage(this, from, from.Subtract(PrimesBigInteger.One).ToString("D"));
                }
                else
                {
                    PrimesBigInteger d       = PrimesBigInteger.One;
                    PrimesBigInteger counter = PrimesBigInteger.Zero;

                    while (d.CompareTo(from) < 0)
                    {
                        if (PrimesBigInteger.GCD(d, from).Equals(PrimesBigInteger.One))
                        {
                            counter = counter.Add(PrimesBigInteger.One);
                            FireOnMessage(this, from, counter.ToString("D"));
                        }
                        d = d.Add(PrimesBigInteger.One);
                    }

                    FireOnMessage(this, from, counter.ToString("D"));
                }

                from = from.Add(PrimesBigInteger.One);
            }

            FireOnStop();
        }
示例#25
0
        public void Execute(PrimesBigInteger value)
        {
            CancelTestThread();
            log.Clear();

            m_Value = value;

            if (m_Value.Mod(2).CompareTo(0) == 0)
            {
                log.Info(string.Format(rsc.Primetest.mr_iseven, value));
                FireEventCancelTest();
            }
            else
            {
                log.Info(string.Format(rsc.Primetest.mr_shiftcalc, m_Value - 1));
                GetShift(value);
                log.Info(string.Format((m_shift == 1) ? rsc.Primetest.mr_shiftedright : rsc.Primetest.mr_shiftedright2, m_shift, m_Value - 1, m_d));
                log.Info("");

                switch (KindOfTest)
                {
                case KOD.Random:
                    ExecuteRandom();
                    break;

                case KOD.Systematic:
                    ExecuteSystematic();
                    break;
                }
            }
        }
示例#26
0
        private bool IsPrimitiveRoot(PrimesBigInteger root, PrimesBigInteger prime)
        {
            if (!PrimesBigInteger.GCD(root, prime).Equals(PrimesBigInteger.One))
            {
                return(false);
            }

            PrimesBigInteger primeMinus1 = prime.Subtract(PrimesBigInteger.One);
            PrimesBigInteger k           = PrimesBigInteger.One;

            while (k.CompareTo(primeMinus1) < 0)
            {
                if (m_Jump)
                {
                    return(false);
                }
                if (root.ModPow(k, prime).Equals(PrimesBigInteger.One))
                {
                    return(false);
                }
                k = k.Add(PrimesBigInteger.One);
            }

            return(true);
        }
示例#27
0
 void ircSystematic_Execute(PrimesBigInteger from, PrimesBigInteger to, PrimesBigInteger second)
 {
     if (ForceGetInteger != null)
     {
         ForceGetInteger(new ExecuteIntegerDelegate(Execute));
     }
 }
示例#28
0
        protected override void DoExecute()
        {
            FireOnStart();
            PrimesBigInteger from = m_From;

            while (from.CompareTo(m_To) <= 0)
            {
                PrimesBigInteger result = PrimesBigInteger.Zero;
                PrimesBigInteger k      = PrimesBigInteger.One;
                while (k.CompareTo(from) <= 0)
                {
                    if (from.Mod(k).Equals(PrimesBigInteger.Zero))
                    {
                        PrimesBigInteger phik = EulerPhi(k);
                        result = result.Add(phik);
                        FireOnMessage(this, from, result.ToString());
                    }
                    k = k.Add(PrimesBigInteger.One);
                }
                FireOnMessage(this, from, result.ToString());
                from = from.Add(PrimesBigInteger.One);
            }

            FireOnStop();
        }
示例#29
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);
        }
示例#30
0
        private void DoExecute(bool doExecute)
        {
            PrimesBigInteger from   = null;
            PrimesBigInteger to     = null;
            PrimesBigInteger second = null;

            GetValue(ref from, ref to);
            if (to == null)
            {
                to = from;
            }

            if (Execute == null || !doExecute)
            {
                return;
            }
            if (from == null || to == null)
            {
                return;
            }

            if (SecondParameterPresent && pnlSecondParameter.IsEnabled)
            {
                ValidateSecondInput(ref second);
            }

            LockControls();
            Execute(from, to, second);
        }