given any two numbers a,b and an upper and lower bound for the sum of reciprocals of a certain class of integers between a and b, without any direct calculation how can optimal upper and lower bounds for the number of terms in the sum be found
I don't see how one could do this without 'any direct calculation'. However, one can find the integral of the characteristic function * (1/x) over [a,b] to estimate the sum.
I have to assume that when you say "a certain class of integers" you mean a congruence class, something like the integers in an arithmetic progression a+n b. In that case this is not difficult. Given two numbers A,B, B>A, the number of integers in an arithmetic progression a+n b that are equal to or between two Numbers A, B , and therefore the number of terms in the required sum is [(B-a)/b]-[(A-a)/b] where [] denotes the integer part of the quantity in the brackets. A more interesting question is: given the integers A, B and an arithmetic progression (a,b) to come up with upper and lower bounds for the sum of the reciprocals of the terms in the arithmetic progression that are between or equal to A,B.