此题过于为简单题,读代码即可读懂。

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()) {
            int n = sc.nextInt();
            int count = -1; // 记录当前的值
            int sum = 0; // 记录总和
            for(int i=0; i<n; i++) {
                count += 3;
                sum += count;
            }
            System.out.println(sum);
        }
    }
}