def is_pandigital_product(x, y): product_string = str(x) + str(y) + str(x*y) if len(product_string) != 9: return False return is_pandigital(int(product_string))
def forms_pandigital(n): concat = str(n) for i in itertools.count(2): concat += str(n*i) if len(concat) == 9 and is_pandigital(int(concat)): return int(concat) elif len(concat) > 9: return 0