Here's a Python function to factor a prime number using trial division:
main.py347 chars16 lines
You can call this function like so: factorize(131)
and it will return [131]
. If you call factorize(156)
it will return [2, 2, 3, 13]
, which are the prime factors of 156.
gistlibby LogSnag