number theory libraries / project euler

Discussion in 'Python' started by eliben, Feb 18, 2009.

  1. eliben

    eliben Guest

    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
    eliben, Feb 18, 2009
    #1
    1. Advertising

  2. eliben

    Kurt Smith Guest

    On Wed, Feb 18, 2009 at 2:18 PM, eliben <> 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 :) ?


    There's Sage: http://www.sagemath.org/ -- I believe it aims to do
    everything that Mathematica can do and more, and I know it has some
    number theory libs, too. I haven't had the occasion to use it myself.

    Much of the fun of project euler problems is 'rolling your own,' or
    implementing a classic algorithm from a description of it on
    Wikipedia. A good sieve of eratosthenes in pure Python (that I tend
    to use quite often) is here:

    http://code.activestate.com/recipes/117119/

    You can find some combinatorics in numpy, I believe.

    Often the solutions are one-to-five liners, if you've thought the
    problem through. Too much dependence on external libraries robs the
    project euler problems of their fun, IMO.

    Best,

    Kurt
    Kurt Smith, Feb 18, 2009
    #2
    1. Advertising

  3. eliben

    Paul Rubin Guest

    eliben <> writes:
    > 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.


    The idea of Project Euler is you are supposed to find clever enough
    methods to solve the problems that speed of the software libs is NOT
    important.
    Paul Rubin, Feb 18, 2009
    #3
  4. eliben

    Mensanator Guest

    On Feb 18, 2:18 pm, eliben <> 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.
    Mensanator, Feb 18, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Piet den Dulk

    Euler tour problem

    Piet den Dulk, Oct 24, 2003, in forum: Java
    Replies:
    6
    Views:
    1,152
    Piet den Dulk
    Oct 27, 2003
  2. Bruno Desthuilliers
    Replies:
    30
    Views:
    1,062
    paulhankin
    Sep 19, 2007
  3. Replies:
    3
    Views:
    517
    Tim Prince
    Mar 16, 2008
  4. Panagiotis Atmatzidis
    Replies:
    7
    Views:
    134
    Giampiero Zanchi
    Dec 21, 2009
  5. Roy Smith

    Python is awesome (Project Euler)

    Roy Smith, Dec 31, 2012, in forum: Python
    Replies:
    6
    Views:
    153
    Roy Smith
    Jan 3, 2013
Loading...

Share This Page