while循环
sum = 0
x = 1
n = 1
while True:
x = 2**(n-1)
n = n+1
sum =sum+x
if n>20:
break
print sum
sum = 0
x = 1
n = 1
while True:
sum=sum+x
x=2**n
n=n+1
if n>20:
break
print sum
这两段程序的运行结果为什么是一致的??
sum = 0
x = 1
n = 1
while True:
x = 2**(n-1)
n = n+1
sum =sum+x
if n>20:
break
print sum
sum = 0
x = 1
n = 1
while True:
sum=sum+x
x=2**n
n=n+1
if n>20:
break
print sum
这两段程序的运行结果为什么是一致的??
2015-06-17
举报