结果不一样
sum = 0 x = 1 n = 1 while True: if n > 20: break sum = sum + x x = x * 2 n = n + 1 print sum 1048575 然而 sum = 0 x = 1 n = 1 while True: if n > 20: break n = n + 1 x = x * 2 sum = sum + x print (sum) 2097150 为什么?
sum = 0 x = 1 n = 1 while True: if n > 20: break sum = sum + x x = x * 2 n = n + 1 print sum 1048575 然而 sum = 0 x = 1 n = 1 while True: if n > 20: break n = n + 1 x = x * 2 sum = sum + x print (sum) 2097150 为什么?
2016-11-09
举报