[SciPy-user] prime factorization...

Joe Harrington jh@physics.ucf....
Wed Jun 17 12:39:01 CDT 2009


fred <fredmfp@gmail.com>:
>Is there any function in scipy that gives the prime factorization?

>ie 50 -> [5, 5, 2]?

There may be a solution in sympy:

http://mail.python.org/pipermail/python-list/2008-March/653138.html

There is also a linux 'factor' program that does numbers up to around 1.8e19:

factor 18440000000000000000
18440000000000000000: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 461

If you're looking for a quick-and-dirty solution, that could be
wrapped.  The code is likely GPL, though, so not good for integrating
into numpy/scipy.  I'm sure there must be other code out there that
isn't, nor are the algorithms patented.

I've wanted this capability in numpy/scipy for a while.  Factoring
seems like a basic thing you'd want, but whenever I suggest adding a
little basic thing, people try to pile on a lot of not-basic stuff
that then makes it inconceivable to add anything.

--jh--


More information about the SciPy-user mailing list