# Collatz猜想

Collatz 猜想粵拼ko1 lats4 caai1 soeng2，英文：Collatz conjecture，中文：奇偶歸一猜想3n+1 猜想冰雹猜想角谷猜想哈塞猜想烏拉姆猜想敘拉古猜想）係一個數學猜想，個猜想係噉樣嘅：首先，你求祈揀個正數 ${\displaystyle n}$。晒呢，如果個數字係雙數嚟嘅話就將佢除以二，如果係單數嘅話就將佢乘三加一。跟住就用呢個方法嚟係噉將呢個數字係噉變。個猜想就係任你初頭嗰陣時揀乜嘢正數都好，所整出嚟嘅數列最後都係會達到 1 呢個數字嘅。

## 問題嘅陳述

• 如果個數字係雙數嘅話，將個數字除以二
• 如果個數字係單數嘅話，將個數字乘三加一

${\displaystyle f(n)={\begin{cases}{\frac {n}{2}}&{\text{if }}n\equiv 0{\pmod {2}}\\[4px]3n+1&{\text{if }}n\equiv 1{\pmod {2}}.\end{cases}}}$

## 計數機驗證

def collatz(number):
while number != 1:
if number % 2 == 0:
number = number // 2
elif number % 2 == 1:
number = number*3 + 1
print(number)

collatz(int(input('輸入一個正整數')))


## 參考資料

1. O'Connor, J.J.; Robertson, E.F. (2006). "Lothar Collatz". St Andrews University School of Mathematics and Statistics, Scotland.
2. Maddux, Cleborne D.; Johnson, D. Lamont (1997). Logo: A Retrospective. New York: Haworth Press. p. 160. ISBN 0-7890-0374-0. The problem is also known by several other names, including: Ulam's conjecture, the Hailstone problem, the Syracuse problem, Kakutani's problem, Hasse's algorithm, and the Collatz problem.
3. 根據 Template:Named ref p. 4, 「Syracuse問題」呢個名係由Hasse喺1950年代去訪問雪城大學嗰陣時提議嘅。
4. Pickover, Clifford A. (2001). Wonders of Numbers. Oxford: Oxford University Press. pp. 116–118. ISBN 0-19-513342-0.
5. "Hailstone Number". MathWorld. Wolfram Research.
6. Hofstadter, Douglas R. (1979). Gödel, Escher, Bach. New York: Basic Books. pp. 400–2. ISBN 0-465-02685-0.
7. Guy, Richard K. (2004). ""E17: Permutation Sequences"". Unsolved problems in number theory (第3版). Springer-Verlag. pp. 336–7. ISBN 0-387-20860-7. Zbl 1058.11001.
8. Guy, R. K. (1983). "Don't try to solve these problems". Amer. Math. Monthly. 90 (1): 35–41. doi:10.2307/2975688. JSTOR 2975688. By this Erdos means that there aren't powerful tools for manipulating such objects.