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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

The number of divisors of 84 : 12

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

The number of divisors of 12 : 4


My Personal Notes arrow_drop_up

Coder Machine Learner Social Activist Vocalist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.