fork download
  1. memo=[]
  2. def func(n)
  3. r=0
  4. while(n!=3)
  5. n=(n%2==0)?n/=2:(n+1)*3
  6. r+=1
  7. end
  8. r
  9. end
  10.  
  11. maxv=maxi=0
  12. 2.upto(10000){|n|
  13. w=func(n)
  14. if w > maxv
  15. maxv=w
  16. maxi=n
  17. end
  18. }
  19. p ["value = ",maxv]
  20. p ["index = ",maxi]
  21.  
Success #stdin #stdout 0.21s 7412KB
stdin
Standard input is empty
stdout
["value = ", 239]
["index = ", 7421]