/// <summary> /// https://projecteuler.net/problem=61 /// </summary> /// <param name="arguments"></param> /// <returns></returns> public static Result CyclicalFigurateNumbers(Problem arguments) { var numbers = UtilityMath.GetPolygonalNumbers <int>(1009, 9999).ToArray(); var count = numbers.Length; var types = Enumerable.Range(0, count).ToArray <int>(); // array of polygonal number types used var setNumberOrder = UtilityString.GeneratePermutations <int>(types); // permutation of the types indicat1ing all combinations of these in a sequence of numbers var s = UtilityMath.GetNumericalCyclicalSet(setNumberOrder, numbers); var answer = s.set.Sum().ToString(); var message = string.Format("The sum of the only ordered set of six cyclic 4-digit numbers for which each polygonal type: triangle, square, pentagonal, hexagonal, heptagonal, and octagonal, is represented by a different number in the set is {0}.", answer); if (Answers[arguments.Id] != answer) { message += string.Format(" => INCORRECT ({0})", Answers[arguments.Id]); } var r = new Result(arguments.Id, message) { Answer = answer }; return(r); }