题解 | #等差数列#
等差数列
http://www.nowcoder.com/practice/f792cb014ed0474fb8f53389e7d9c07f
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int n = sc.nextInt();
int start = 2;
int sum = 0;
for (int i = 0; i < n; i++) {
sum += start;
start += 3;
}
System.out.println(sum);
}
}
}