对比两个求等差数列1+2+…+n的和的程序,其算法效率?( )
程序1:
n=int(input())
s=(1+n)*n/2
print(s)
程序2:
s=0
for i in range(n+1):
s=s+i
程序1比程序2高
程序2比程序1高
一样高
不能判断