With the help of sympy.core() method, we can calculate the of a positive integer n. core(n, t) calculates the t-th power free part of n.
If nās prime factorization is :
then
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.
Example #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))Ā |
Output:
core(24, 2) = 6
Example #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)) |
Output:
core(14641, 3) = 11