Skip to content
Related Articles

Related Articles

Python | sympy.smoothness() method
  • Last Updated : 05 Sep, 2019

With the help of sympy.smoothness() method, we can find smoothness and power-smoothness of a given number. The smoothness of a number is its largest prime factor and the power-smoothness is its largest divisor raised to its multiplicity.

Syntax:
smoothness(n)

Parameter:
n – It denotes the number for which the smoothness and power-smoothness is calculated.

Returns:
Returns a tuple of smoothness and power-smoothness of the given number.

Example #1:






# import smoothness() method from sympy
from sympy.ntheory.factor_ import smoothness
   
n = 64
   
# Use smoothness() method 
smoothness_n, power_smoothness_n = smoothness(n) 
       
print("The smoothness and power-smoothness of {} is {} and {} respectively".
      format(n, smoothness_n, power_smoothness_n))

Output:

The smoothness and power-smoothness of 64 is 2 and 64 respectively

Example #2:




from sympy.ntheory.factor_ import smoothness
   
n = 2**4 * 13
   
# Use smoothness() method 
smoothness_n, power_smoothness_n = smoothness(n) 
       
print("The smoothness and power-smoothness of {} is {} and {} respectively".
      format(n, smoothness_n, power_smoothness_n))

Output:

The smoothness and power-smoothness of 208 is 13 and 16 respectively

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :