On Mon, Jan 12, 2009 at 9:20 PM, bob gailer <bgai...@gmail.com> wrote:

> for natnum in range(1000):
>  if not (natnum % 3 or natnum % 5): # adds 1 if divisible by 3 and/or 5
>   cume += 1
>  if not natnum % 15: # remove one of the ones if divisible by 15
>   cume -= 1

This subtraction is not needed because the multiples of 15 are not
double-counted. The 'or' condition counts multiples of 15 just once.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to