代码如下:
import java.util.Scanner;
public class App {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入n:");
int n = scanner.nextInt();
int sum1 = 0;
int sum2 = 0;
for (int i = 1; i <= n; i++) {
sum1 += i;
sum2 += sum1;
}
System.out.println("结果:" + sum2);
}
}
运行结果:
需要的话,留个邮箱,一会写完发给你