import java.math.BigDecimal; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int n = scanner.nextInt(); BigDecimal num = BigDecimal.ONE; for (int i = 2; i <= n; i++) { num = num.multiply(BigDecimal.valueOf(i)); } System.out.println(num); } } }
[BASIC-30] 阶乘计算,布布扣,bubuko.com
原文地址:http://blog.csdn.net/u011506951/article/details/26704449