Beispiel #1
0
        static long d(long n)
        {
            List <long> divisors = fg.GeneratorDistinctDivisor(n);
            long        result   = 0;

            for (int i = 0; i < divisors.Count; i++)
            {
                if (divisors[i] < n)
                {
                    result += divisors[i];
                }
            }
            return(result);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Dictionary <int, List <int> > c = new Dictionary <int, List <int> >();
            FactorsGenerator fg             = new FactorsGenerator();

            for (int i = 1; i < 500; i++)
            {
                int count = fg.GeneratorDistinctDivisor(i).Count;
                if (!c.ContainsKey(count))
                {
                    c.Add(count, new List <int>());
                }
                c[count].Add(i);
                continue;
            }
        }
Beispiel #3
0
        static AbundantCheckNumber BuildAbundantCheckNumber(long value, FactorsGenerator fg)
        {
            List <long> divisors = fg.GeneratorDistinctDivisor(value);
            long        sum      = 0;

            foreach (long div in divisors)
            {
                if (div < value)
                {
                    sum += div;
                }
            }
            if (sum == value)
            {
                return new AbundantCheckNumber()
                       {
                           Value = value, NumberType = NumberType.Perfect, DivisorsSum = sum
                       }
            }
            ;

            if (sum < value)
            {
                return new AbundantCheckNumber()
                       {
                           Value = value, NumberType = NumberType.Deficient, DivisorsSum = sum
                       }
            }
            ;

            if (sum > value)
            {
                return new AbundantCheckNumber()
                       {
                           Value = value, NumberType = NumberType.Abundant, DivisorsSum = sum
                       }
            }
            ;

            return(new AbundantCheckNumber()
            {
                Value = value, NumberType = NumberType.NotChecked, DivisorsSum = sum
            });
        }
    }
}