highest = 0 start = int(raw_input("Enter the starting number: ")) end = int(raw_input("Enter the ending number: ")) for n in range(start, end + 1): current = n times = 1 while n != 1: times += 1 if n % 2 != 0: n = 3 * n + 1 else: n = n / 2 if times > highest: highest = times number = current print "The number with the highest amount of cycles between " + str(start) + " and " + str(end) + " with " + str(highest) + " cycles was: " + str(number)