输出内容:print("hello ZSQ")
过程性求和:i = 1
sum = 0
while i <=500:
sum += i
i += 1
print(f"1-500的和为:{sum}")
高斯求和:sum = 0
for i in range(501):
if i<=500:
sum +=i
print(f"1-500求和为:{sum}")
函数:def func(n):
sum = 0;
for i in range(1,n+1):
sum += i
return sum
b = func(500)
print(b)