def test(x): sq = 12 * x + 1 ss = int(sq ** 0.5) if ss * ss != sq: return False if ss % 6 != 5: return False return True def main(): max = 3000 for n in xrange(4, max): for m in xrange(n + 1, max): a = 3 * (m * m + n * n) - m - n b = (m - n) * (3 * (m + n) - 1) if test(a) and test(b): print a / 2, b / 2, m, n return main()