示例#1
0
        /// <summary>
        /// Creates a new amicable number
        /// </summary>
        /// <param name="num">The amicable number</param>
        public AmicableNumber(long num)
        {
            long sum1, sum2;

            this.Number = num;
            FactorFinder f = new FactorFinder(num);

            f.Find();
            f.Factors.RemoveAt(f.Factors.Count - 1);
            sum1 = f.Factors.Sum <long>(x => x);
            f    = new FactorFinder(sum1);
            f.Find();
            f.Factors.RemoveAt(f.Factors.Count - 1);
            sum2          = f.Factors.Sum <long>(x => x);
            this.Amicable = sum1;
            if (this.Number == sum2 && this.Amicable != this.Number)
            {
                this.IsAmicable = true;
            }
        }
示例#2
0
        /// <summary>
        /// Proper number
        /// </summary>
        /// <param name="num">The number to be converted as a proper number</param>
        public ProperNumber(long num)
        {
            this.Number = num;
            FactorFinder f = new FactorFinder(num);

            f.Find(true);
            Factors = f.Factors;
            long sum = Factors.Sum <long>(X => X);

            if (sum == this.Number)
            {
                this.Type = ProperNumberType.Perfect;
            }
            else if (sum > this.Number)
            {
                this.Type = ProperNumberType.Abundant;
            }
            else
            {
                this.Type = ProperNumberType.Deficient;
            }
        }