题解 | #等差数列#
等差数列
https://www.nowcoder.com/practice/f792cb014ed0474fb8f53389e7d9c07f
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader bufferedReader = new BufferedReader(isr); String input = bufferedReader.readLine(); Integer lastNum = Integer.parseInt(input); int result = 0; for (int i = 0; i < lastNum; i++) { result +=(2+3*i); } System.out.print(result); } }