输入一个整数
输出一个整数
4
20
n=int(input()) sum=0 for i in range(1,n+1): for j in range(1,i+1): sum+=j print(sum)
a = int(input()) b = [(1+i)*i/2 for i in range(1,a+1)] print("{:.0f}".format(sum(b)))
n=int(input()) sum=0 total=0 for i in range(1,n+1): sum+=i total+=sum print(total)
def lj(n): sum = 0 for i in range(1,n+1): sum = sum +i return sum n = int(input()) sum = 0 for i in range(1,n+1): sum = sum +lj(i) print(sum)
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题