Andreas Klöckner's web page
  • About
  • Research
  • Teaching
  • Archives

Fermat’s Last Python Script

Date Tue 18 September 2007 Tags fermat / math / mindless-link-propagation / python
def fermat(n):
    """Returns triplets of the form x^n + y^n = z^n.
    Warning! Untested with n > 2.
    """
    from itertools import count
    for x in count(1):
        for y in range(1, x+1):
            for z in range(1, x**n+y**n + 1):
                if x**n + y**n == z**n:
                    yield x, y, z

Nicked from the earthbound kid.

  • About

    I teach and do research on scientific computing at the University of Illinois at Urbana-Champaign.

  • Arxiv
  • Github
  • RSS Feed