public void TestFor284()
        {
            IList <Int32> divisorsOfNumber = Divisors.DivisorsOfNumber(284);

            Int32[] expected = new[] { 1, 2, 4, 71, 142 };
            Assert.AreEqual(expected.Length, divisorsOfNumber.Count);

            foreach (Int32 i in expected)
            {
                Assert.Contains(i, (ICollection)divisorsOfNumber);
            }
        }
        public void TestFor220()
        {
            IList <Int32> divisorsOfNumber = Divisors.DivisorsOfNumber(220);

            Int32[] expected = new[] { 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110 };
            Assert.AreEqual(expected.Length, divisorsOfNumber.Count);

            foreach (Int32 i in expected)
            {
                Assert.Contains(i, (ICollection)divisorsOfNumber);
            }
        }
Beispiel #3
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);
        }