num= int(input()) total = 0 for i in range(num+1): count = 0 for j in range(i+1): count+=j total+=count print(total)
如题目所示,采用最简单的思路,双层for循环
外面循环一次,里面循环一圈
先定义里面的初始值为0,for循环里面累加的和,在和外面的个数相加