Python | sympy.antidivisors() method
Last Updated :
09 Sep, 2019
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:
from sympy.ntheory.factor_ import antidivisors
n = 24
antidivisors_n = antidivisors(n)
print ( "The anti-divisors of {} : {}" . format (n, antidivisors_n))
|
Output:
The anti-divisors of 24 : [7, 16]
Example #2:
from sympy.ntheory.factor_ import antidivisors
n = 128
antidivisors_n = antidivisors(n)
print ( "The anti-divisors of {} : {}" . format (n, antidivisors_n))
|
Output:
The anti-divisors of 128 : [3, 5, 15, 17, 51, 85]
Share your thoughts in the comments
Please Login to comment...