Python| sympy.smoothness() 方法
借助sympy.smoothness()方法,我们可以找到给定数字的平滑度和幂平滑度。一个数的平滑度是它最大的素因数,幂平滑度是它的最大除数提升到它的多重性。
Syntax:
smoothness(n)
Parameter:
n – It denotes the number for which the smoothness and power-smoothness is calculated.
Returns:
Returns a tuple of smoothness and power-smoothness of the given number.
示例 #1:
# import smoothness() method from sympy
from sympy.ntheory.factor_ import smoothness
n = 64
# Use smoothness() method
smoothness_n, power_smoothness_n = smoothness(n)
print("The smoothness and power-smoothness of {} is {} and {} respectively".
format(n, smoothness_n, power_smoothness_n))
输出:
The smoothness and power-smoothness of 64 is 2 and 64 respectively
示例 #2:
from sympy.ntheory.factor_ import smoothness
n = 2**4 * 13
# Use smoothness() method
smoothness_n, power_smoothness_n = smoothness(n)
print("The smoothness and power-smoothness of {} is {} and {} respectively".
format(n, smoothness_n, power_smoothness_n))
输出:
The smoothness and power-smoothness of 208 is 13 and 16 respectively