[Python] python通过while循环计算1到n的和 →→→→→进入此内容的聊天室

来自 , 2020-08-31, 写在 Python, 查看 109 次.
URL http://www.code666.cn/view/00c17237
  1. def sum(n):
  2.     result = 0
  3.     i = 1
  4.     while i <= n:
  5.         result += i
  6.         i += 1
  7.     return result

回复 "python通过while循环计算1到n的和"

这儿你可以回复上面这条便签

captcha