public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入数字");
int t = sc.nextInt();
System.out.println("请输入次数");
int n = sc.nextInt();
System.out.println(getNumber(t,n));
}
public static int getNumber(int t,int n){
int result=0;
for(int i =0;i<=n;i++){
result =result+(i*t);
}
return result;
}
|