kill(all)$

van=facebook.com/LearningCalculus$

k:8$

print("x   y   a   n   m  ")$
for i: 1 thru k do
    for a: 2 thru 2 do
        for n: i+1 thru i+1 do
            for m: 2*(i+1)-1 thru 2*(i+1)-1 do
            (
                x: 2^i, y: x,
                if (x + y = a^n) and (x^2+y^2 = a^m) then
                    print(x, y, a, n, m)
            )$

for i: 1 thru k do
    print(2^i, 2^i, 2, i+1, 2*(i+1)-1)$

30^5;

30^4;

8 * 8 * 30^3;