public static void Main() { WriteLine("Problem 23"); long answer = Problem23.Solve(); WriteLine($"answer = {answer}"); }
static void Main(string[] args) { Problem23 prog = new Problem23(); BitArray abundantNumbers = new BitArray(28124); BitArray test = new BitArray(28124); //Console.WriteLine(prog.isPerfectNumber(28)); //Console.WriteLine(prog.isPerfectNumber(12)); int sumtotal = 0; for (int i = 2; i <= 28123; i++) { if (prog.isAbundantNumber(i)) { abundantNumbers[i] = true; } } for (int i = 2; i <= 28123; i++) { if (abundantNumbers[i]) { for (int j = 2; j <= 28123; j++) { if (i + j > 28123) { break; } if (abundantNumbers[j]) { int sum = i + j; test[sum] = true; } } } } // copy paste got me for (int i = 1; i <= 28123; i++) { if (!test[i]) { sumtotal += i; } } Console.WriteLine("Answer = " + sumtotal); Console.ReadKey(); }