Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Defining x,y,z to be variables and then using them as integers is not really appropriate. The indentation was also missing, along with an if.

You do not need to declare the variables if you use them in a range:

sage: for x in range(-100,101):
....:     for y in range(-100,101):
....:         for z in range(-100,101):
....:             if x^4+y^4 == z^3:
....:                 print(x,y,z)

You can also use more advanced iterators and shorten the code:

sage: import itertools
sage: for x,y,z in itertools.product(srange(-100,101),repeat=3):
....:     if x^4 + y^4 == z^3:
....:         print(x,y,z)