Wednesday, October 8, 2025
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
32342 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6712 POSTS0 COMMENTS
Nicole Veronica
11875 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11937 POSTS0 COMMENTS
Shaida Kate Naidoo
6833 POSTS0 COMMENTS
Ted Musemwa
7092 POSTS0 COMMENTS
Thapelo Manthata
6786 POSTS0 COMMENTS
Umr Jansen
6789 POSTS0 COMMENTS