Con la ayuda del método sympy.reduced_totient() , podemos encontrar la función totient reducida de Carmichael o lambda(n) en SymPy. reduce_totient(n) o es el m > 0 más pequeño tal que para todos los k son primos relativos a n .
Sintaxis: reduce_totient(n)
Parámetro:
n – Denota un número entero.Devuelve: Devuelve el entero más pequeño m > 0 tal que k m % n es igual a 1 para todos los k primos relativos a n.
Ejemplo 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)
Producción:
lambda(8) = 2
Ejemplo #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))
Producción:
lambda(30) = 4
Publicación traducida automáticamente
Artículo escrito por rupesh_rao y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA