a=0; for i=1:10000 if a+(1/i)<5 a=a+(1/i) i++ else break end end