Friday, January 30, 2026
HomeLanguagesPython | 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 
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32478 POSTS0 COMMENTS
Milvus
122 POSTS0 COMMENTS
Nango Kala
6849 POSTS0 COMMENTS
Nicole Veronica
11978 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12065 POSTS0 COMMENTS
Shaida Kate Naidoo
6987 POSTS0 COMMENTS
Ted Musemwa
7222 POSTS0 COMMENTS
Thapelo Manthata
6934 POSTS0 COMMENTS
Umr Jansen
6917 POSTS0 COMMENTS