#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define printclock cerr<<"\nTime : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\t";
//-------------------------------------------------------------------|
int32_t main()
{
fastio()
int test = 1;
cin >> test;
while(test--)
{
int x, n, m, k;
cin >> x >> n;
m = x / n;
int ans = 0;
// part 1 : x / 1 to x / sqrt(x)
for(int i = 1; i * i <= x && i <= n; i++)
{
ans += x / i;
k = i;
}
// edge cases adjustment
if(k == x / k && k * k != x)
ans -= (x / k - x / (k + 1)) * k;
// part 2 : to x / (x / 1) to x / (x / sqrt(x))
for(int i = 1; i * i < x; i++)
ans += (x / i - x / (i + 1)) * i;
// removing from x / (x) to x / (x / (n + 1)) if required
for(int i = 1; i < m && i * i < x; i++)
ans -= (x / i - x / (i + 1)) * i;
// edge case adjustment
if(m > 0)
ans -= (x / m - n) * m;
cout << ans << endl;
}
printclock
}