[Tutor] Need help w/ a for loop

Kent Johnson kent37 at tds.net
Fri Oct 24 13:44:01 CEST 2008


On Fri, Oct 24, 2008 at 6:51 AM, W W <srilyk at gmail.com> wrote:

> for i in range(1, n+1):
>     x = x + (m * (i % 2)) * (4.0/(i*2))

This will omit every other term (when i%2 ==0) and it divides by the
even numbers, not odd ones.

Kent


More information about the Tutor mailing list