Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sol(n):
- c=0
- while n!=1:
- if n%2==0:
- n=n//2
- else:
- n=(3*n)+1
- c=c+1
- return c
- def swap(a,b):
- temp=a
- a=b
- b=temp
- while 1:
- a,b=map(int,input().split())
- if a==0 and b==0:
- break
- else:
- x=[]
- y=[]
- temp=a
- while temp<=b:
- x.append(sol(temp))
- y.append(temp)
- temp+=1
- for i in range(b):
- for j in range(b):
- if x[i]>x[j]:
- swap(x[i],x[j])
- swap(y[i],y[j])
- print(x)
- print(y)
- print("Between",a,"and",b,y[0],"generates the longest sequence of",x[0],"values."
- )
Advertisement
Add Comment
Please, Sign In to add comment