Python | sympy.antidivisors() method

With the help of sympy.antidivisors() method, we can find the anti-divisors of a given number in sorted order by default.

Syntax: antidivisors(n, generator=False)

Parameter:
n – It denotes an integer.
generator – If generator is True an unordered generator object is returned, otherwise it returns a sorted list of anti-divisors. It is False by default.



Returns: Returns a list of anti-divisors of the given integer.

Example #1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# import antidivisors() method from sympy
from sympy.ntheory.factor_ import antidivisors
  
n = 24
  
# Use antidivisors() method 
antidivisors_n = antidivisors(n) 
      
print("The anti-divisors of {} : {}".format(n, antidivisors_n))

chevron_right


Output:

The anti-divisors of 24 : [7, 16]

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# import antidivisors() method from sympy
from sympy.ntheory.factor_ import antidivisors
  
n = 128
  
# Use antidivisors() method 
antidivisors_n = antidivisors(n) 
      
print("The anti-divisors of {} : {}".format(n, antidivisors_n))

chevron_right


Output:

The anti-divisors of 128 : [3, 5, 15, 17, 51, 85]


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.