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
> ...
cool thanks thats what i changed it to than just now i changed to do
something else and instead of leaving the program running for 4 or 5
days as i had been i got my answer in less than a second ^_^"
i realized that i was wasting way to much time checking every
possible answer because the nu
Max,
> just wondering if theirs a way to check if a larger number is even
> or
> odd
I notice this is homework so I won't give a direct answer.
But look at the mod operator '%' - It returns the remainder
of an integer division. An even number is exactly divisible
by 2.
HTH,
Alan G.
"max base
cool thanks
the problem was from a math book imp 1 but i already did the work i
was just interested in what number had the most steps i could fin
wanted to get to 1000 imagine how dismayed i was when it crashed at 965
On Sep 3, 2007, at 8:23 PM, Andrew James wrote:
> I'd just go with
>
> if n
Hi Max,
A better way to check if a number is odd or even would be to find the
remainder after it is divided by two.
for instance: 4 divided by 2 = 2 with 0 remainder
5 divided by 2 = 2 with 1 remainder
6 divided by 2 = 3 with 0 remainder
7