public static int Solve() { List <int> successfulStarts = new List <int>(); List <int> chain = new List <int>(); for (int i = 3; i < 1000000; i++) { chain.Add(i); int current = (int)i.ToString().Sum(x => EulerUtilities.Factorial(x - 48)); while (!chain.Contains(current)) { chain.Add(current); current = (int)current.ToString().Sum(x => EulerUtilities.Factorial(x - 48)); if (chain.Count == 60 && chain.Contains(current)) { successfulStarts.Add(i); } if (chain.Count > 60) { break; } } chain.Clear(); } return(successfulStarts.Count); }
public static int Solve() { int totalSum = 0; for (int i = 10; i < 2540160; i++) { int sum = 0; foreach (char c in i.ToString()) { sum += (int)EulerUtilities.Factorial((int)Char.GetNumericValue(c)); } if (sum == i) { totalSum += i; } } return(totalSum); }