/**
* X!:X的阶乘
*
* @author Administrator
* @version 1.0
*/
public class Factorial {
/**
* 主方法:阶乘运算
*
* @param args
*/
public static void main(String[] args) {
long result = 1;
int i = (int) (Math.random() * 10);// 小于10的随机数!考虑长度问题还是就计算下10以内的吧
System.out.println("随机取得一个小于100的整数" + i);
for (int j = 0; j < i; j++) {
result = result * (j+1);
}
System.out.println(i + "的阶乘结果是" + result);
}
}
阶乘的算法
最新推荐文章于 2019-03-29 16:29:51 发布
455

被折叠的 条评论
为什么被折叠?



