Project Euler [Problem 45]
2問目よ
問題
Triangular, pentagonal, and hexagonal
Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:
- Triangle 1, 3, 6, 10, 15, ...
- Pentagonal 1, 5, 12, 22, 35, ...
- Hexagonal 1, 6, 15, 28, 45, ...
It can be verified that .
Find the next triangle number that is also pentagonal and hexagonal.
私訳
三角数、五角数そして六角数
三角数、五角数、そして六角数はそれぞれ以下で与えられる
- 三角 1, 3, 6, 10, 15, ...
- 五角 1, 5, 12, 22, 35, ...
- 六角 1, 6, 15, 28, 45, ...
であることが確かめられる.
次の、三角数であり、しかも五角数でも六角数でもあるものを探せ.
解答方針
一番隙間が多いのは六角数なので、六角数を生成して五角かつ三角であるものを探す。