Friday, October 17, 2025
HomeLanguagesPython | sympy.reduced_totient() method

Python | sympy.reduced_totient() method

With the help of sympy.reduced_totient() method, we can find the Carmichael reduced totient function or lambda(n) in SymPy. reduced_totient(n) or \lambda(n) is the smallest m > 0 such that k^m \equiv 1 \mod n for all k relatively prime to n.

Syntax: reduced_totient(n)

Parameter:
n – It denotes an integer.

Returns: Returns the smallest integer m > 0 such that km % n is equal to 1 for all k relatively prime to n.

Example #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)


Output:

lambda(8) =  2 

Example #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)) 


Output:

lambda(30) =  4
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS