#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using int32 = std::int_fast32_t; using int64 = std::int_fast64_t; using uint32 = std::uint_fast32_t; using uint64 = std::uint_fast64_t; #define MOD 1000000007 int main(void) { std::ios::sync_with_stdio(false); std::cin.tie(0); uint64 n, m; std::cin >> n >> m; if (m > n) { std::cout << "0\n"; return 0; } uint64 f = 1; for (uint64 i = 1;i < n-1;++i) { (f *= i) %= MOD; } std::vector prime; std::vector ch(n + 1, 1); for (uint32 i = 2;i <= n;++i) { if (ch[i]) { prime.push_back((uint64)i); for (uint32 j = i;j <= n;j += i) { ch[j] = 0; } } } uint64 ans; uint64 temp = n / m; ans = temp*(temp - 1) % MOD; (ans *= f) %= MOD; for (uint64 i = 0;i < prime.size();++i) { temp = m * prime[i]; if (temp > n) break; temp = n / temp; temp = temp*(temp - 1) % MOD; (temp *= f) %= MOD; ans = ans >= temp ? ans - temp : ans + MOD - temp; } std::cout << ans << "\n"; return 0; }