📜  Python| sympy.reduced_totient() 方法

📅  最后修改于: 2022-05-13 01:54:38.249000             🧑  作者: Mango

Python| sympy.reduced_totient() 方法

借助sympy.reduced_totient()方法,我们可以在 SymPy 中找到 Carmichael 约简函数或 lambda(n)。 reduce_totient(n)\lambda(n)是最小的m > 0使得k^m \equiv 1 \mod n对于所有kn互质。

示例 #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