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
32688 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7057 POSTS0 COMMENTS
Nicole Veronica
12198 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12293 POSTS0 COMMENTS
Shaida Kate Naidoo
7182 POSTS0 COMMENTS
Ted Musemwa
7447 POSTS0 COMMENTS
Thapelo Manthata
7160 POSTS0 COMMENTS
Umr Jansen
7150 POSTS0 COMMENTS