# Python | sympy.primefactors() method

With the help of sympy.primefactors() method, we can find the prime factors of a given number. Unlike factorint(), primefactors() does not return -1 or 0.

Syntax: primefactors(n)

Parameter:
n – It denotes an integer.

Returns: Returns a list of prime factors of the given integer.

Example #1:

 `# import primefactors() method from sympy ` `from` `sympy ``import` `primefactors ` ` `  `n ``=` `2` `*` `6``*``21` `*` `11` ` `  `# Use primefactors() method  ` `primefactors_n ``=` `primefactors(n)  ` `     `  `print``(``"The prime factors of {} : {}"``.``format``(n, primefactors_n)) `

Output:

```The prime factors of 2772 : [2, 3, 7, 11]
```

Example #2:

 `# import primefactors() method from sympy ` `from` `sympy ``import` `primefactors ` ` `  `n ``=` `-``210` ` `  `# Use primefactors() method  ` `primefactors_n ``=` `primefactors(n)  ` `     `  `print``(``"The prime factors of {} : {}"``.``format``(n, primefactors_n)) `

Output:

```The prime factors of -210 : [2, 3, 5, 7]
```

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.