from functools import reduce def gcd(a, b): r = a % b if r: return gcd(b, r) else: return b def lcm(a, b): return a * b // gcd(a, b) def solve(n): m = n + 1 res1 = 1 res2 = reduce(lcm, [i for i in range(1, m+1)]) while True: if lcm(res1, m) ...