为什么不应该是n=0,而是n=1?
sum = 0
x = 1
n = 1
while True:
if n>20:
break
sum =sum + x
x =x*2
n= n+1
print sum
n=0,那执行n=n+1,那才是1开始啊,如果n=1,那不是2开始吗?
sum = 0
x = 1
n = 1
while True:
if n>20:
break
sum =sum + x
x =x*2
n= n+1
print sum
n=0,那执行n=n+1,那才是1开始啊,如果n=1,那不是2开始吗?
2018-05-24
举报