// Note that T(1 + 2k) = H(1 + k), so every HexagonalNumber is a TriangleNumber // Proof: T(1 + 2k) = (1 + 2k)*(1 + 2k + 1) / 2 = (1 + 2k)*(1 + k), // and H(n + k) = (1 + k)*(2(1 + k) - 1) = (1 + k)*(1 + 2k) public static List <long> GetFirstNTriangleNumbersWhichAreAlsoPentagonalAndHexogonal(int count) { var listOfNumbersFound = new List <long>(); long n = 1; while (count != 0) { var nthTriangleNumber = GetNthTriangleNumber(n); if (PentagonNumberHelper.IsPentagonalNumber(nthTriangleNumber)) { listOfNumbersFound.Add(nthTriangleNumber); count--; } n += 2; } return(listOfNumbersFound); }
public static long GetSolutionOfProblem44() { return(PentagonNumberHelper.GetMinimalDistanceOfPentagonalNumbersForWhichSumAndDifferenceArePentagonal()); }