class Solution {
  public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     *
     * @param n int整型
     * @return int整型
     */
    long long ans = 1;
    const int mod = 1000000007;
    int factorial(int n) {
        // write code here
        for (int i = 2; i <= n; ++i)
            ans = (ans * i) % mod;
        return ans;
    }
};

一、题目考察的知识点

阶乘思想

二、题目解答方法的文字分析

阶乘思想,注意要在每一步乘积的过程中取模,如果只在最后一步取模可能会出错

三、本题解析所用的编程语言

c++