s=0;                          % partial sum
c=0;                          % carry
for j=1:N
  y=1/j+c;
  t=s+y;                      % next partial sum, with roundoff
  c=(s-t)+y;                  % recapture the error and store as carry
  s=t;
end
s=s+c
