Skip to content

Instantly share code, notes, and snippets.

@Yoiter
Last active January 27, 2018 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yoiter/8cd05c3608e893414b61a83ea961d9ae to your computer and use it in GitHub Desktop.
Save Yoiter/8cd05c3608e893414b61a83ea961d9ae to your computer and use it in GitHub Desktop.
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