题解 | #等差数列#
等差数列
https://www.nowcoder.com/practice/f792cb014ed0474fb8f53389e7d9c07f
def sum_func(n, a = 2): sum = a *n + 3 * n * (n - 1) / 2 return int(sum) while True: try: input_num = int(input()) print(sum_func(input_num)) except: break
记住等差数列的计算公式,定义函数,然后输出即可。