1 方法一:2 s = 13 sum = 04 for i in range(1,6):5 s = s*i6 sum += s7 print(s)8 print(sum)
1 方法二:效率低,每次都要重新算k2 3 n = 0 4 for i in range(1,6):5 k = 16 for j in range(1, i + 1):7 k = k * j8 n = n + k9 print(n)
本文共 282 字,大约阅读时间需要 1 分钟。
1 方法一:2 s = 13 sum = 04 for i in range(1,6):5 s = s*i6 sum += s7 print(s)8 print(sum)
1 方法二:效率低,每次都要重新算k2 3 n = 0 4 for i in range(1,6):5 k = 16 for j in range(1, i + 1):7 k = k * j8 n = n + k9 print(n)
转载于:https://www.cnblogs.com/JerryZao/p/9404458.html