x = x * 2 和x = x + 2^(n -1) ,为什么不能啊,没明白
sum = 0
x = 1
n = 1
while True:
sum = sum + x
x = x + 2^(n-1)
n = n + 1
if n > 20:
break
print sum
sum = 0
x = 1
n = 1
while True:
sum = sum + x
x = x + 2^(n-1)
n = n + 1
if n > 20:
break
print sum
2018-12-27
举报