YUNNNN @ 2023-12-07 20:58:10
package _issue;
//求阶乘之和
import java.math.BigInteger;
import java.util.Scanner;
public class _1 {
public static void main(String[]args)
{
Scanner s=new Scanner(System.in);
int num=s.nextInt();
BigInteger sum=new BigInteger("0");
for (int i = 1; i <= num; i++) {
BigInteger a=new BigInteger("1");
for (int j = 1; j <= i; j++) {
a=a.multiply(BigInteger.valueOf(j));
}
sum=sum.add(a);
}
System.out.println(sum);
}
}
by xiezheyuan @ 2023-12-07 21:19:56
@YUNNNN
类名改成 Main
就可以过了。
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[]args)
{
Scanner s=new Scanner(System.in);
int num=s.nextInt();
BigInteger sum=new BigInteger("0");
for (int i = 1; i <= num; i++) {
BigInteger a=new BigInteger("1");
for (int j = 1; j <= i; j++) {
a=a.multiply(BigInteger.valueOf(j));
}
sum=sum.add(a);
}
System.out.println(sum);
}
}
求关
by Zpril_20211017 @ 2023-12-08 21:51:03
@sz_mane 注意帖子编号
by Special_Tony @ 2023-12-09 11:14:24
@Zpril 艹
by YUNNNN @ 2023-12-12 17:31:39
@xiezheyuan OK谢谢