Triangular, pentagonal, and hexagonal
Triangle, pentagonal, and hexagonal numbers are generated by the following formulas:
|Triangle||Tn=n(n+1)/2||1, 3, 6, 10, 15, …|
|Pentagonal||Pn=n(3n−1)/2||1, 5, 12, 22, 35, …|
|Hexagonal||Hn=n(2n−1)||1, 6, 15, 28, 45, …|
It can be verified that T285 = P165 = H143 = 40755.
Find the next triangle number that is also pentagonal and hexagonal.
Following from last problem, we can use similar strategy to check if a number is a triangular, pentagonal, and hexagonal by verifying the following two formulas from here:
where P(s, n) = x and s is equal to the number of sides and n is the nth s-gonal number.
Another key observation from above is that every hexagonal number is also a triangular number (you can verify this using the formula above).
Therefore, we can minimize our check by finding the next hexagonal number (starting with n = 144) and verify if it is also a pentagonal number.