using System; using System.Collections.Generic; using System.Linq; public class Program { static long ModFactorial(long n) { long mod = 1000000007; if (n == 0) return 0; //nがmod以上ならXは0になる if (n >= mod) return 0; long[] catche_list = { 1, 927880474, // (1 * 10^8)! % mod 933245637, // (2 * 10^8)! % mod 668123525, // (3 * 10^8)! % mod 429277690, // (4 * 10^8)! % mod 733333339, // (5 * 10^8)! % mod 724464507, // (6 * 10^8)! % mod 957939114, // (7 * 10^8)! % mod 203191898, // (8 * 10^8)! % mod 586445753, // (9 * 10^8)! % mod 698611116, // (10 * 10^8)! % mod }; //nを10^8で割った商がcatche_listのインデックスになり起点が求まる long start = n / 100000000; long ans = catche_list[start]; //起点から階乗の計算を始める for (long i = start * 100000000 + 1; i <= n; i++) ans = ans * i % mod; return ans; } static void Main() { long n; { long[] vs = Console.ReadLine().Split().Select(_ => long.Parse(_)).ToArray(); n = vs[0]; } long value = ModFactorial(n); Console.WriteLine(value); } }