I'm stuck trying to figure out how to find out which number in a range entered for a hailstone sequence has the longest length of numbers total including the starting number itself. This is what I have so far:
elif choice is apart of a menu
getValidInt() is a function that makes sure the value entered.
hailstone() is where i have my hailstone loop.
I know I need some type of if statement that saves the new number that has the longest chain, then once I know the number I just print out the length of the longest sequence.
elif choice == 'L' or choice == 'l':
startNum = getValidInt('Enter the first number in the range', 1, 10000)
stopNum = getValidInt('Enter the first number in the range', startNum, 10000)
longLength = 0
for i in range(startNum, stopNum + 1):
longLength = hailstone(i)
if i >= longLength:
longLength = i
print longLength
any help would be great I'm stumped. Thanks.