+

Python | Sympy.reduced_totient () method

Using the sympy.reduced_totient () method we can find Carmichael`s shorthand totient function or lambda (n) in SymPy.  selected_totient (n) or smallest m & gt; 0 such that for all k relatively simple to n .

Syntax: reduced_totient (n)

Parameter:
n - It denotes an integer.

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

Example # 1:

# import redu_totient () method from sympy

from sympy.ntheory import reduced_totient

 

n = 8

 
# Use the extended_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)

Exit:

 lambda (8) = 2  

Example # 2:

# import redu_totient () method from sympy

from sympy.ntheory import reduced_totient

  

n = 30

 
# Use the extended_totient () method

reduced_totient_n = reduced_totient (n) 

 

print ( "lambda ({}) = {}" . format (n, reduced_totient_n)) 

Exit :

 lambda (30) = 4 
Get Solution for free from DataCamp guru