借助於sympy.reduced_totient()方法,我們可以在SymPy中找到Carmichael簡化的totient函數或lambda(n)。 reduced_totient(n)或是最小的m> 0這樣
對所有人ķ相對於ñ。
用法: reduced_totient(n)
參數:
n - 它表示一個整數。
返回:返回最小整數m> 0,使km對於相對於n的所有k,%n等於1。
範例1:
# import reduced_totient() method from sympy
from sympy.ntheory import reduced_totient
n = 8
# Use reduced_totient() method
reduced_totient_n = reduced_totient(n)
print("lambda({}) = {} ".format(n, reduced_totient_n))
# 1 ^ 2 = 1 (mod 8), 3 ^ 2 = 9 = 1 (mod 8),
# 5 ^ 2 = 25 = 1 (mod 8) and 7 ^ 2 = 49 = 1 (mod 8)
輸出:
lambda(8) = 2
範例2:
# import reduced_totient() method from sympy
from sympy.ntheory import reduced_totient
n = 30
# Use reduced_totient() method
reduced_totient_n = reduced_totient(n)
print("lambda({}) = {} ".format(n, reduced_totient_n))
輸出:
lambda(30) = 4
相關用法
- Python os.dup()用法及代碼示例
- Python next()用法及代碼示例
- Python set()用法及代碼示例
- Python object()用法及代碼示例
- Python bytes()用法及代碼示例
- Python os.times()用法及代碼示例
- Python os.chmod用法及代碼示例
- Python hash()用法及代碼示例
- Python os.ftruncate()用法及代碼示例
- Python os.truncate()用法及代碼示例
- Python os.fsdecode()用法及代碼示例
- Python dict pop()用法及代碼示例
- Python os.abort()用法及代碼示例
- Python os.WEXITSTATUS()用法及代碼示例
注:本文由純淨天空篩選整理自rupesh_rao大神的英文原創作品 Python | sympy.reduced_totient() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。