[Tutor] checking if a number is evan or odd
max baseman
dos.fool at gmail.com
Mon Sep 3 22:06:48 CEST 2007
hello just a quick check in, it's about the same program i was asking
about before ive let it sit for a few days now and i reached a number
to high to convert to a decimal by adding 0.0
here's the program:
count=1
numstart=268549802
number=0
high=0
a=0
while 1==1:
numstart=numstart+1
number=numstart
count=1
while number !=1:
if number/2 == (number+0.0)/2:
number=number/2
else:
number=(number*3)+1
count=count+1
if count > a:
a=count
print numstart,":",count
after a few days i got this error:
Traceback (most recent call last):
File "homework6high.py", line 11, in <module>
if number/2 == (number+0.0)/2:
OverflowError: long int too large to convert to float
just wondering if theirs a way to check if a larger number is even or
odd
thanks
More information about the Tutor
mailing list