So, this is the result of repeated use of several factoring-oriented functions for project euler. It's quite small, and any semi-competent programmer could probably come up with a faster or more efficient solution, but these were mine and they work perfectly well for my purposes. Everything is pretty straightforward, I figured the docstring was enough documentation and it isn't commented, but use it if you want. Everything I write, unless it says otherwise (which it won't unless it's for a job or for someone else to sell) is released under the GPL, despite my general perception that no one will ever want to reproduce it. In any event, the library is here.
I'm particularly happy with the primefactor function. It's my first successful (and actually useful) attempt at recursion, and it works very well. As the docstring suggests, the getprimes function (which is utilized by primefactor) slows down around n = 100000 or so, but I've optimized it the best I can, and I think it's fine for most practical applications. Anyway, enjoy.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment