为啥得到的答案和标题不一致呢?
题目要的是1+2+4+8+16
这是标准答案: sum = 0 x = 1 n = 1 while True: if n > 20: break sum = sum + x x = x * 2 n = n + 1 print sum
标准答案求和为:
1
3
7
15
31
63
127
255
511
1023
2047
4095
8191
16383
32767
65535
131071
262143
524287
1048575
题目要的是1+2+4+8+16
这是标准答案: sum = 0 x = 1 n = 1 while True: if n > 20: break sum = sum + x x = x * 2 n = n + 1 print sum
标准答案求和为:
1
3
7
15
31
63
127
255
511
1023
2047
4095
8191
16383
32767
65535
131071
262143
524287
1048575
2019-04-19
举报