Beispiel #1
0
        public void Run()
        {
            HashSet <Int32> numbers = new HashSet <Int32>();

            for (Int32 i = 0; i < 10000; i++)
            {
                IList <Int32> divisorsOfNumber = Divisors.DivisorsOfNumber(i);
                Int32         b = divisorsOfNumber.Sum();
                Boolean       areAmicablePairs = Divisors.AreAmicablePairs(i, b);

                if (areAmicablePairs)
                {
                    numbers.Add(i);
                    numbers.Add(b);
                }
            }

            Int32 sum = numbers.Sum();

            Console.WriteLine(sum);
        }
        public void AmicablePairs()
        {
            Boolean areAmicablePairs = Divisors.AreAmicablePairs(220, 284);

            Assert.AreEqual(true, areAmicablePairs);
        }