通项公式:
前n
项和:
套用公式即可
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int length = sc.nextInt(); // n
int first = 2, last = 3 * length - 1; // a1, an
System.out.println((first + last) * length / 2);
}
sc.close();
}
}