[Tutor] checking if a number is evan or odd

Kent Johnson kent37 at tds.net
Wed Sep 5 02:12:39 CEST 2007


max baseman wrote:
> here is the program sorry copying it from interactive:
> 
>  >>> number=1
>  >>> count=1000
>  >>> count=0
>  >>> while count < 1000:
> ...     if (number*2)%2 == 0:

This will always be true, you multiply by two then check if the result 
is divisible by two.

Kent

> ...             number=number*2
> ...     else:
> ...             number=(number-1)/3.0
> ...     count=count+1
> ...     print number



More information about the Tutor mailing list