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