# Python | sympy.primepi() method

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

Syntax: primepi(n)

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

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

Example #1:

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

Output:

```The number of prime numbers less than or equal to 10 is 4
```

Example #2:

 `# import primepi() method from sympy ` `from` `sympy ``import` `primepi ` ` `  `n ``=` `150` ` `  `# Use primepi() method  ` `count_primes ``=` `primepi(n)  ` `     `  `print``(``"The number of prime numbers less than or equal to {} is {}"``.``format``(n, count_primes))           `

Output:

```The number of prime numbers less than or equal to 150 is 35
```
My Personal Notes arrow_drop_up Check out this Author's contributed articles.

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.