等差数列 2,5,8,11,14。。。。
(从 2 开始的 3 为公差的等差数列)
输出求等差数列前n项和
输入:275
输出:113575
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;void (async function () {// Write your code herewhile ((line = await readline())) {let tokens = line.split(" ");// 从2开始let num = [2];for (let i = 1; i < line; i++) {let a = num[num.length - 1] + Number(3);num = [...num, a];}let sum = 0;for (let item of num) {sum += item;}console.log(sum);}
})();