number theory libraries / project euler

Mensanator mensanator at
Wed Feb 18 23:36:21 CET 2009

On Feb 18, 2:18 pm, eliben <eli... at> wrote:
> Hello,
> What are some good & recommended number theory libs for Python (or
> accessible interfaces to C libs), for things like primes,
> factorization, etc. Naturally, speed is of utmost importance here.
> In other words, which Python libraries and tools to you use to help
> you solve Project Euler problems :-) ?
> Eli

Also check out the gmpy library, lots of good number theory stuff
like factorial, gcd, lcm, linear congruence, is_prime, next_prime,
(I even found a use for the legendre function), etc.

(no factorization, I have Python call the MIRACL factor program when
I need that)

gmpy is so vital to my work that if they ever stop supporting it,
I will abandon Python.

More information about the Python-list mailing list