Thursday, February 12, 2026
HomeLanguagesPython sympy | sieve.totientrange() method

Python sympy | sieve.totientrange() method

With the help of sympy.sieve.totientrange() method, we can generate all totient numbers for a given range [a, b). It returns a type generator object which can be converted to a list for further operations.

Syntax: sieve.totientrange(a, b)
Parameters:
a – It denotes the start of the range. It is inclusive.
b – It denotes the end of the range. It is not inclusive.
Returns: The method returns a type generator object.

Example #1:




# import sympy 
from sympy import sieve
  
# Use sieve.totientrange() method 
totient_gen = sieve.totientrange(1, 10
totient_list = list(totient_gen)
      
print("Totient numbers for the range of numbers [1, 10) : {}".format(totient_list))  


Output:

Totient numbers for the range of numbers [1, 10) : [1, 1, 2, 2, 4, 2, 6, 4, 6]

Example #2:




# import sympy 
from sympy import sieve
  
# Use sieve.totientrange() method 
totient_gen = sieve.totientrange(8, 20
totient_list = list(totient_gen)
      
print("Totient numbers for the range of numbers [8, 20) : {}".format(totient_list))      


Output:

Totient numbers for the range of numbers [8, 20) : [4, 6, 4, 10, 4, 12, 6, 8, 8, 16, 6, 18]
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32497 POSTS0 COMMENTS
Milvus
128 POSTS0 COMMENTS
Nango Kala
6872 POSTS0 COMMENTS
Nicole Veronica
11996 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12090 POSTS0 COMMENTS
Shaida Kate Naidoo
7009 POSTS0 COMMENTS
Ted Musemwa
7246 POSTS0 COMMENTS
Thapelo Manthata
6959 POSTS0 COMMENTS
Umr Jansen
6950 POSTS0 COMMENTS