Friday, October 3, 2025
HomeLanguagesPython | sympy.divisor_count() method

Python | sympy.divisor_count() method

With the help of sympy.divisor_count() method, we can count the number of divisors of the given integer.

Syntax: divisor_count(n, modulus=1)

Parameter:
n – It denotes an integer.
modulus – It is set to 1 by default. If modulus is not 1 then only those that are divisible by modulus are counted.

Returns: Returns the count of divisors of the given number.

Example #1:




# import divisor_count() method from sympy
from sympy import divisor_count
  
n = 84
  
# Use divisor_count() method 
divisor_count_n = divisor_count(n) 
      
print("The number of divisors of {} : {}".format(n, divisor_count_n))


Output:

The number of divisors of 84 : 12

Example #2:




# import divisor_count() method from sympy
from sympy import divisor_count
  
n = 12
  
# Use divisor_count() method 
divisor_count_n = divisor_count(n, modulus = 2
      
print("The number of divisors of {} : {}".format(n, divisor_count_n))


Output:

The number of divisors of 12 : 4
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32332 POSTS0 COMMENTS
Milvus
85 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11868 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11929 POSTS0 COMMENTS
Shaida Kate Naidoo
6818 POSTS0 COMMENTS
Ted Musemwa
7080 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6776 POSTS0 COMMENTS