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