歐拉 Totient 函數(Phi)計算器
歐拉 totient 函數 φ(n) 計算從 1 到 n 中,除 1 外與 n 沒有公因數的整數個數。
Count of integers in 1..n coprime to 36
12
coprimeCoprime to n
33.3%
Sharing a factor
66.7%
- 1
Distinct prime factors of n
2, 3 - 2
Apply product formula φ(n) = n × Π(1 − 1/p)
36 × (1 − 1/2) × (1 − 1/3) = 12
此計算機如何運作?
歐拉 totient 函數 φ(n) 計算 1 到 n 中與 n 互質的整數個數。將 n 分解為不同質因數 p,計算 φ(n) = n · Π(1 − 1/p)。互質比率 φ(n)/n 等於該乘積,表示 n 以下的隨機整數與 n 互質的概率。
公式
How this is calculated
輸入單個正整數 n(n ≥ 1)。計算器透過試除法分解 n,找出整除它的每個不同質因數 p。重複出現的質因數會被合併,因此只有不同質因數的集合對 totient 有影響。
從 φ = n 開始,對每個不同質因數 p 乘以 (1 − 1/p),實際計算時使用 φ = φ − φ/p 以避免浮點漂移;最終值四捨五入到最近整數。這就是乘積公式 φ(n) = n · Π(1 − 1/p),其成立是因為 totient 函數對互質的質數冪是乘法的。互質比率 φ(n)/n 等於同一乘積,代表 1..n 中隨機整數與 n 互質的概率。
邊界情況:φ(1) = 1(按慣例),質數 n 返回 φ(n) = n − 1,其本身為唯一的質因數。輸入必須為正整數;非整數、小於 1 的值或極大的 n(超過 10^12)將被拒絕。輸出為純計數,無物理單位。
常見問題
按慣例 φ(1) = 1,因為 1 被視為與自身互質,且沒有質因數來減少計數。
質數 p 與 1, 2, …, p − 1 中任何數都無公因數,因此這 p − 1 個整數都與 p 互質,只有 p 本身被排除。
不取決於。乘積 Π(1 − 1/p) 中只出現整除 n 的不同質因數;其重數被吸收進前導因子 n 中。
也稱為
TG we-Calculate Editorial Team. (2026). 歐拉 Totient 函數(Phi)計算器 [Online calculator]. TG we-Calculate. https://we-calculate.com/zh-tw/calculator/euler-totient-calculator
TG we-Calculate Editorial Team. "歐拉 Totient 函數(Phi)計算器." TG we-Calculate. 2026. https://we-calculate.com/zh-tw/calculator/euler-totient-calculator.
TG we-Calculate Editorial Team, "歐拉 Totient 函數(Phi)計算器," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/zh-tw/calculator/euler-totient-calculator
@misc{wecalculate_euler_totient_calculator, title = {歐拉 Totient 函數(Phi)計算器}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/zh-tw/calculator/euler-totient-calculator}}, year = {2026}, note = {TG we-Calculate} }
這個計算機對您有幫助嗎?
