sum=0; N=0; for j=1:100 sum=sum+1/j; N=j; if sum>=5 sum=sum-1/N; N=N-1; break; end end