Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:
Triangle
$T_n=n(n+1)/2$
$1, 3, 6, 10, 15, \dots$
Pentagonal
$P_n=n(3n – 1)/2$
$1, 5, 12, 22, 35, \dots$
Hexagonal
$H_n=n(2n – 1)$
$1, 6, 15, 28, 45, \dots$
It can be verified that $T_{285} = P_{165} = H_{143} = 40755$.
Find the next triangle number that is also pentagonal and hexagonal.
To solve this problem, we will have to create three sequences based on the formula provided; one for the triangle numbers (T_n), one for the pentagonal numbers (P_n), and one for the Hexagonal numbers (H_n). Then we need to find the same number (other than 40755, which is already provided) from all three sequences.
Since it’s known that every hexagonal number is a triangular number, we only have to check every hexagonal number to see if it is also a pentagonal number.
The Python code below does just that. It generates hexagonal numbers and checks if they are pentagonal. It starts from the 144th term because it is asked for the next number after the 143rd term:
“`python
def is_pentagonal(x):
n = (((24 * x) + 1) ** 0.5 + 1) / 6
return n == int(n)
n = 144
while True:
hexagonal = n * (2 * n – 1)
if is_pentagonal(hexagonal):
print(hexagonal)
break
n += 1
“`
When you run this Python code, it generates hexagonal numbers, starting with the 144th term, checks if that hexagonal number is pentagonal, and once it finds a number that satisfies both conditions, it prints the number and stops.
Executing this program gives the result 1533776805. Hence, `$T_{55385} = P_{31977} = H_{27693} = 1533776805$` is the next triangle number that is also pentagonal and hexagonal.
More Answers:
Coded Triangle NumbersSub-string Divisibility
Pentagon Numbers