整数序列求和。用户输入一个正整数N,计算1到N相加之后的结果。 算法源码 sum=0 none=1 while(none): N=int(input("请输入一个正整数N:")) if N>0: none=0 for i in range(1,N+1): sum=sum+i print(sum)