Friday, September 5, 2025
HomeLanguagesPython | sympy.compositepi() method

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:




# 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
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11861 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS