# Python sympy | sieve.extend() method

With the help of sympy.sieve.extend() method, we can grow the sieve to cover all the prime numbers less than equal to a given natural number.

Syntax: sieve.extend(N)
Parameter:
N – It denotes the number up to which the sieve is extended.
Returns: The function does not return anything.

Example #1:

 `# import sympy  ` `from` `sympy ``import` `sieve ` ` `  `# Use sieve.extend() method  ` `sieve.extend(``50``)  ` `prime_list ``=` `sieve._list ` `     `  `print``(``"Prime Numbers up to 50 : {}"``.``format``(prime_list))   `

Output:

```Prime Numbers up to 50 : array('l', [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47])
```

Example #2:

 `# import sympy  ` `from` `sympy ``import` `sieve ` ` `  `# Use sieve.extend() method  ` `sieve.extend(``100``)  ` `prime_list ``=` `sieve._list ` `     `  `print``(``"Prime Numbers up to 100 : {}"``.``format``(prime_list))   `

Output:

```Prime Numbers up to 100 : array('l', [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97])
```

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

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.