Python| sympy.antidivisors() 方法
借助sympy.antidivisors()方法,我们可以默认按排序顺序找到给定数字的反除数。
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.
示例 #1:
# 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))
输出:
The anti-divisors of 24 : [7, 16]
示例 #2:
# 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))
输出:
The anti-divisors of 128 : [3, 5, 15, 17, 51, 85]