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 number%2 == 0: > number = number/2 > > Why do you need to convert it to a float? > > Off topic: > Is this a PE problem? I remember doing the same thing. > > max baseman wrote: >> 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 >> >> _______________________________________________ >> Tutor maillist - Tutor@python.org >> http://mail.python.org/mailman/listinfo/tutor >> >> >> _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor