Wednesday, July 3, 2024
HomeLanguagesPythonPython | sympy.core() method

Python | sympy.core() method

With the help of sympy.core() method, we can calculate the core_t(n) of a positive integer n. core(n, t) calculates the t-th power free part of n.
If n’s prime factorization is :

n = \prod_{i=1}^\omega p_i^{m_i}

then

core_t(n) = \prod_{i=1}^\omega p_i^{m_i \mod t}

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 

Thapelo Manthata
I’m a desktop support specialist transitioning into a SharePoint developer role by day and Software Engineering student by night. My superpowers include customer service, coding, the Microsoft office 365 suite including SharePoint and power platform.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments