# testing all numbers from 1 to upper limit! # variables are initialised highestchain=0 count=0 # stores integer currently being tested print ("ODDS AND EVENS") # user establishes a range for checking uppernum=int(input("Choose your upper limit:")) while uppernum>count: count+=1 # count stores integer currently being tested x=count # x holds value while testing each step step=1 # step counts number of links in chain while x!=1: # loop creates chain if x%2==0: x=int(x/2) else: x=int(x*3+1) step+=1 print("The number",count,"has a chain length of",step) if step>highestchain: # highestchain stores the highest length chain currently found highestchain=step highestint=count print() print("All integers up to your upper limit have been tested and the one \nwhich created the longest chain was",highestint,"with a length of",highestchain) # fix: endless loop printing highest chain