Python| sympy.core() 方法
借助sympy.core()方法,我们可以计算出一个正整数n 。 core(n, t)计算n的第 t 个无幂部分。
如果n的素数分解为 :
然后
Syntax: core(n, t=2)
Parameter:
n – It denotes an integer.
t – It denotes an integer(optional). Default for t is 2.
Returns: Returns the t-th power free part of n.
示例 #1:
# import core() method from sympy
from sympy.ntheory.factor_ import core
n = 24
k = 2
# Use core() method
core_n_k = core(n, k)
print("core({}, {}) = {} ".format(n, k, core_n_k))
输出:
core(24, 2) = 6
示例 #2:
# import core() method from sympy
from sympy.ntheory.factor_ import core
n = 11**4
k = 3
# Use core() method
core_n_k = core(n, k)
print("core({}, {}) = {} ".format(n, k, core_n_k))
输出:
core(14641, 3) = 11