The harmonic series has a lot of roundoff error for large N. Does your program work for N = 10?
For N = 1,000,000 S = 14.393, and the difference between adjacent terms may be less than roundoff.
Use compensated addition
Kahan summation algorithm - Wikipedia[
^]
and store each term in an array S[]. Then binary search the array for the target value.