#include #include #include #include #include #include #include using namespace std; constexpr int P = 1000000007; vector prime_vector(int n) { if (n <= 2) return vector(0); int m = (int)sqrt(n - 1); vector q(n); for (int i = 2; i <= m; i++) { if (q[i]) continue; for (int j = i * i; j < n; j += i) { q[j] = true; } } vector p; p.reserve(n / log(n * 0.329)); for (int i = 2; i < n; i++) { if (!q[i]) p.push_back(i); } return p; } int main() { int n, m; cin >> n >> m; int l = n / m; auto pv = prime_vector((int)sqrt(l) + 1); int64_t r = 0; for (int i = 2; i <= l; i++) { int k = i, t = i; for (int p : pv) { if (t < p * p) break; if (t % p == 0) { while (t % p == 0) t /= p; k -= k / p; } } if (t > 1) k -= k / t; r += k; } r *= 2; for (int i = 1; i <= n - 2; i++) { r *= i; r %= P; } cout << r << endl; return 0; }