Skip to content
Related Articles

Related Articles

Improve Article

Python | sympy.compositepi() method

  • Last Updated : 27 Aug, 2019

With the help of sympy.compositepi() method, we can find the number of composite numbers less than or equal to a given number.

Syntax: compositepi(n)

Parameter:
n – It denotes the number up to which the count of composite number is calculated.

Returns: Returns the number of composite numbers less than or equal to n.

Example #1:






# import compositepi() method from sympy
from sympy import compositepi
  
n = 10
  
# Use compositepi() method 
count_composites = compositepi(n) 
      
print("The number of composites numbers less than or equal to {} is {}".format(n, count_composites))

Output:

The number of composites numbers less than or equal to 10 is 5

Example #2:




# import compositepi() method from sympy
from sympy import compositepi
  
n = 100
  
# Use compositepi() method 
count_composites = compositepi(n) 
      
print("The number of composites numbers less than or equal to {} is {}".format(n, count_composites))          

Output:

The number of composites numbers less than or equal to 100 is 74

 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. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :