Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
print("type x to quit")
b = input("up to what number: ")
while b != "x":
li = []#list that stores the numbers produced
List = []#list that contains all lists
for i in range(2,int(b)):
li.append(i)
while i != 1:
if i % 2 == 0: #even
i = i/2
li.append(i)
else:
i = 3*i+1 #odd
li.append(i)
List.append(li)
li = []
print(max(List,key=len)) #prints the longest list, out of all lists
print(len(max(List,key=len)))#prints the length of the list
b = input("up to what number: ")
#the first number is the number that produced the list
#hi Mr.Robertson
# resource - https://stackoverflow.com/questions/13400876/python-length-of-longest-sublist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.