Ask Your Question

Revision history [back]

How about something like this:

from sage.rings.sum_of_squares import two_squares.pyx

for d in srange(1, 100):
    try:
        e, f = two_squares_pyx(d)
        try:
            g, h = two_squares_pyx(e)
            print(d, e, f, g, h)
        except ValueError:
            try:
                g, h = two_squares_pyx(f)
                print(d, e, f, g, h)
            except ValueError:
                continue
    except ValueError:
        continue

How about something like this:

from sage.rings.sum_of_squares import two_squares.pyx

for d in srange(1, 100):
    try:
        # See if d is a sum of two squares: d = e^2 + f^2
        e, f = two_squares_pyx(d)
        try:
            # Now test e.
            g, h = two_squares_pyx(e)
            print(d, e, f, g, h)
        except ValueError:
            # If e didn't work, try f.
            try:
                g, h = two_squares_pyx(f)
                print(d, e, f, g, h)
            except ValueError:
                continue
    except ValueError:
        continue

How about something like this:

from sage.rings.sum_of_squares import two_squares.pyx
two_squares_pyx

for d in srange(1, 100):
    try:
        # See if d is a sum of two squares: d = e^2 + f^2
        e, f = two_squares_pyx(d)
        try:
            # Now test e.
            g, h = two_squares_pyx(e)
            print(d, e, f, g, h)
        except ValueError:
            # If e didn't work, try f.
            try:
                g, h = two_squares_pyx(f)
                print(d, e, f, g, h)
            except ValueError:
                continue
    except ValueError:
        continue