¡@

Home 

python Programming Glossary: primefactors

I have a Python list of the prime factors of a number. How do I (pythonically) find all the factors?

http://stackoverflow.com/questions/3643725/i-have-a-python-list-of-the-prime-factors-of-a-number-how-do-i-pythonically-f

times it is a factor. After that working on the resulting primefactors list with repetitions itertools.combinations does just what.. you'll just require the combinations of length 2 to len primefactors 1 items included the combinations of just one are the prime.. original number if you want those too just use range 1 len primefactors 1 instead of the range 2 len primefactors which my main suggestion..

Fast prime/factorization module

http://stackoverflow.com/questions/4643647/fast-prime-factorization-module

so this will fully factor every composite 1000000 def primefactors n sort False factors limit int n .5 1 for checker in smallprimes.. not fully factor switch to pollard brent factors.extend primefactors factor # recurse to factor the not necessarily prime factor.. return factors def factorization n factors for p1 in primefactors n try factors p1 1 except KeyError factors p1 1 return factors..