public void TestIsAmicablenumbers() { /* * For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; * therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220. */ Assert.True(AmicableNumbers.IsAmicablenumbers(220)); Assert.True(AmicableNumbers.IsAmicablenumbers(284)); Assert.False(AmicableNumbers.IsAmicablenumbers(100)); Assert.False(AmicableNumbers.IsAmicablenumbers(28)); }
public int GetSumOfAmicablenumbers(int from, int to) { int SumOfAmicablenumbers = 0; for (int i = from; i < to; i++) { if (AmicableNumbers.IsAmicablenumbers(i)) { SumOfAmicablenumbers += i; } } return(SumOfAmicablenumbers); }