题解 | #等差数列#
等差数列
https://www.nowcoder.com/practice/f792cb014ed0474fb8f53389e7d9c07f?tpId=37&tqId=21323&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D2%26tpId%3D37%26type%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=
import sys ''' 初始化等差数列 ''' a1= 2 d=3 n=int(input()) def conculaten(a1,d,n): ''' 利用求等差数列的公式求等差数列 ''' an = a1+(n-1)*d sn = int((a1+an)*n/2) print(sn) conculaten(a1,d,n)