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:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)) 

chevron_right


Output:

core(24, 2) =  6 

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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))

chevron_right


Output:

core(14641, 3) =  11 


My Personal Notes arrow_drop_up

Coder Machine Learner Social Activist Vocalist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.