Last active
January 27, 2018 06:04
-
-
Save Yoiter/8cd05c3608e893414b61a83ea961d9ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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