• Source
    1. ///(output)1.ans是什麼,找到紅色output的最後三個字
    2. /*
    3. maximum cycle length
    4. 最大 循環 長度
    5. */
    6. ///(output)2.所以去找斜體字cycle-lenth
    7. /*
    8. 斜體字後面說:the cycle length of 22 is 16
    9. */
    10. ///(output)3.找到以22為例子的敘述
    11. /*
    12. Given the input 22,the following sequence of number will be printed
    13. 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1
    14. 發現他有規律,順便找一下規律
    15. */
    16. /*
    17. 規律題目有給:
    18. (3)if(n=1)就停止
    19. (4) if(n是奇數)令n=3n+1
    20. (5) else 令n=n/2
    21. */
    22. ///(output)4.發現從22數到1剛好是16,所以ans=max cycle length=16
    23. /*
    24. input output
    25. a b a b max