Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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
click to hide/show revision 2
No.2 Revision

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
click to hide/show revision 3
No.3 Revision

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