题解 | #等差数列#
等差数列
http://www.nowcoder.com/practice/f792cb014ed0474fb8f53389e7d9c07f
// 利用等差数列前n项和公式 n(a1+aN)/2
while(line = readline()) {
const num = parseInt(line);
print(num * (2 + 2 + 3*(num -1)) / 2);
}
等差数列
http://www.nowcoder.com/practice/f792cb014ed0474fb8f53389e7d9c07f
// 利用等差数列前n项和公式 n(a1+aN)/2
while(line = readline()) {
const num = parseInt(line);
print(num * (2 + 2 + 3*(num -1)) / 2);
}
相关推荐