On 04/07/17 03:40, Rafael Skovron wrote: > def m(i): > total = 0 > for i in range(1,i+1,1): > total+=(i/(i+1)) > return total
convert the numerator to a float. Otherwise you are using integer division. (I'm guessing you are running Python 2.7?) You could also import division from future: from __future__ import division Alternatively you could try running Python v3. PS, Its probably not a great idea to use i as both the iteration variable and the input parameter. It easily causes confusion. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor