sympy
library?At its core, sympy
is a library used for symbolic mathematics.
We use pip
to install sympy
. Refer to the following command:
pip install sympy
primefactors
methodThe primefactors
method is used to return a sorted list of prime factors of a given number.
Note: Prime factors are prime numbers that completely divide the given number to get zero as the remainder.
sympy.primefactors(n)
n
: This is the number for which prime factors need to be obtained.The method returns the prime factors of the given number.
import sympyn = 100print("The prime factors of %s is %s" % (n, sympy.primefactors(n)))
sympy
package.n
.sympy.primefactors()
method to obtain the prime factors of n
.