return(k)def suan(x): global a try: return a["3^{}-1".format(x)] except: b=3*(suan(x-1)+1)-1 a["3^{}-1".format(x)]=b return(b)def bing(x):
if x%2==0:
return x//2
else:
return x*3+1z=0z3=[(0,0)]while True: try: b = suan(2 * n - 1) c = suan(2 * n) blist = set() clist = set() b2 = b while True: b2 = int(bing(b2)) if b2 in list(a.values()): blist.add(b2) if b2 == 1: break c2 = c while True: c2 = int(bing(c2)) if c2 in list(a.values()): clist.add(c2) if c2 == 1: break m = 0
for i in (blist & clist):
if i > m:
m = i if z < m:
z = m
z3 = [(2 * n - 1, 2 * n)] elif z == m:
z3.append((2 * n - 1, 2 * n)) print("{}. {}({})和{}({}),其失踪的孩子是{}({});".format(n - 1, b, "3^{}-1".format(2 * n - 1), c, "3^{}-1".format(2 * n),m, shi(m))) n += 1 except: breakprint("其中最大的孩子是{}({}),来自:".format(z,shi(z)))