Python | sympy.compositepi() method

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

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

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

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


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.