Java中的阶乘除数
以下是一个Java程序,用于查找数字的阶乘除数。
程序
import java.util.Scanner;
public class DivisorsOfFactorial {
public static long fact(int i) {
if(i <= 1) {
return 1;
}
return i * fact(i - 1);
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("输入n值:");
int n = sc.nextInt();
int result = 0;
long fact = fact(n);
for (int i = 1; i<= fact; i++) {
if (fact%i == 0) {
result = result+i;
}
}
System.out.println(result);
}
}输出结果
输入n值: 4 60
热门推荐
10 古风祝福语唯美简短亲情
11 关于早晨的祝福语简短
12 求助短信生日祝福语简短
13 新婚抖音祝福语简短
14 给司机老师祝福语简短
15 生日祝福语简短搞笑女儿
16 发给导师的祝福语简短
17 表达家人的祝福语简短
18 员工对同事祝福语简短