PythonGenOther1

Choose a starting number. If the number is even then divide it by two or, if it’s odd then add one. Stop when you get to one.

End = 50  

for n in range(1,End):  
  temp = n  
  length = 0  
  while temp != 1:  
    if temp % 2 == 0:  
      temp /=2  
    else:  
      temp += 1  
    length += 1  
  print("Starting at ", n, " the chain length is: ", length)  

It quickly became apparent that the longest chain up the a given value is the closest power of two to it, add one.

Starting at  1  the chain length is:  0  
Starting at  2  the chain length is:  1  
Starting at  3  the chain length is:  3  
Starting at  4  the chain length is:  2  
Starting at  5  the chain length is:  5  
Starting at  6  the chain length is:  4  
Starting at  7  the chain length is:  4  
Starting at  8  the chain length is:  3  
Starting at  9  the chain length is:  7