memo=[]
def func(n)
r=0
while(n!=3)
n=(n%2==0)?n/=2:(n+1)*3
r+=1
end
r
end
maxv=maxi=0
2.upto(10000){|n|
w=func(n)
if w > maxv
maxv=w
maxi=n
end
}
p ["value = ",maxv]
p ["index = ",maxi]
bWVtbz1bXQpkZWYgZnVuYyhuKQoJcj0wCgl3aGlsZShuIT0zKQoJCW49KG4lMj09MCk/bi89MjoobisxKSozCgkJcis9MQoJZW5kCglyCmVuZAoKbWF4dj1tYXhpPTAKMi51cHRvKDEwMDAwKXt8bnwKCXc9ZnVuYyhuKQoJaWYgdyA+IG1heHYKCQltYXh2PXcKCQltYXhpPW4JCQoJZW5kCn0KcCBbInZhbHVlID0gIixtYXh2XQpwIFsiaW5kZXggPSAiLG1heGldCg==