#include<bits/stdc++.h>
using namespace std;
const int N = 1e7+10;
const int mod = 1e9+7;
int n,k;
int main(){
cin>>n>>k;
int ans=0;
for(int i=k+1;i<=n;i++) {
int a=n/i;
int b=i-k;
int c=n%i;
int d=(c-k>=0?c-k+1:0);
ans+=a*b+d;
ans%=mod;
}
cout<<ans%mod;
}
原文:https://www.cnblogs.com/skkyk/p/11674402.html