コード例 #1
0
        public void Problem45()
        {
            HashSet <long> hh = new HashSet <long>(Sequences.HexagonalNumbers().Take(1000000));
            HashSet <long> hp = new HashSet <long>(Sequences.PentagonalNumbers().Take(1000000));

            hh.IntersectWith(hp);

            var matching = hh.Where(h => h.IsTriangle()).ToArray();

            if (matching.Last() != 1533776805)
            {
                throw new InvalidOperationException("Problem not solved correctly");
            }
        }