Problem 44

Triangular, pentagonal, and hexagonal

Problem 46

Triangular, pentagonal, and hexagonal

Problem 45

Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:
It can be verified that T285 = P165 = H143 = 40755.
Find the next triangle number that is also pentagonal and hexagonal.
from math import sqrt


def run():
    # 100000 found by trial and error
    for x in range(40756, 100000):
        c = (x**2 + x) / 2
        y = (0.5 + sqrt(0.25 + 6 * c)) / 3
        z = (1 + sqrt(1 + 8 * c)) / 4

        if y - int(y) == 0 and z - int(z) == 0:
            return (x**2 + x) / 2