length = 0
for n in range(1,101):
print "Sequence #:", n
while n != 1:
print n,
if n % 2 == 0:
n = n / 2
length = length + 1
else:
n = (n * 3) + 1
length = length + 1
if n == 1:
print n
length = length + 1
print "The sequence above contains", length, "numbers"
length = 0
我的问题:
上面的 python 代码计算数字 1 - 100 的冰雹序列,然后显示序列的长度。完成所有计算后,如何显示具有最长序列的数字及其对应的长度?