测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A59190. 对比两个求等差数列1+2+…+n的和的程序,其算法效率?( ) 程序1: n=int(input())

单选题

题目描述

对比两个求等差数列1+2+…+n的和的程序,其算法效率?( )

 程序1:

 n=int(input())
 s=(1+n)*n/2
 print(s)

 程序2:

n=int(input())
 s=0
 for i in range(n+1):
   s=s+i
 print(s)

选项(单选)