The 285th triangular number is also pentagonal and hexagonal. This problem requires us to find the next triangular number that also has this property. This code runs in under half a second on my tablet.
I am running out of easy problems to solve.
from math import sqrt def is_pent(x): j = (sqrt(24*x + 1) + 1) / 6 if j >= 1: if j / int(j) == 1: return True else: return False def is_hex(x): j = (sqrt(8*x + 1) + 1) /4 if j >= 1: if j / int(j) == 1: return True else: return False found = False n = 286 while not found: t = int(n*(n+1)/2) if is_pent(t) and is_hex(t): found = True print(t) n = n + 1