题解 | #牛群全排列数#
牛群全排列数
https://www.nowcoder.com/practice/5ab233c23fcc4c69b81bd5a66c07041c
import java.util.*;
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param n int整型
* @return int整型
*/
public int factorial (int n){
long result = 1;
for (int i = 2; i <= n; i++) {
result = (result * i) % 1000000007;
}
return (int) result;
}
}
本题主要考查递归算法,所用编程语言是java。
我觉得这题在递归算法方面并不是很难,还不如爬梯子,大家看看就好了

查看4道真题和解析