关于给出的答案不晓得x与n具体是怎样相关联的
我自己写的代码如下:
sum = 0
x = 2
n = 1
while True:
sum = x**n - 1
n += 1
if n > 20:
break
print (sum)
但关于给出的答案不晓得x与n具体是怎样相关联的
sum = 0
x = 1
n = 1
while True:
if n > 20:
break
sum = sum + x
x = x * 2
n = n + 1
print sum