Task

Show the first   30   positive integers which are squares but not cubes of such integers.

Optionally, show also the first   3   positive integers which are both squares and cubes,   and mark them as such.




100H: /* CP/M OUTPUT */
BDOS: PROCEDURE (FN, ARG);
    DECLARE FN BYTE, ARG ADDRESS;
    GO TO 5;
END BDOS;
 
PRINT$NUMBER: PROCEDURE (N);
    DECLARE S (7) BYTE INITIAL ('..... $');
    DECLARE (N, P) ADDRESS, C BASED P BYTE;
    P = .S(5);
DIGIT:
    P = P-1;
    C = N MOD 10 + '0';
    N = N/10;
    IF N > 0 THEN GO TO DIGIT;
    CALL BDOS(9, P);
END PRINT$NUMBER;
 
/* SQUARES */
SQUARE: PROCEDURE (N) ADDRESS;
    DECLARE N ADDRESS;
    RETURN N * N;
END SQUARE;
 
/* CUBES */
CUBE: PROCEDURE (N) ADDRESS;
    DECLARE N ADDRESS;
    RETURN N * N * N;
END CUBE;
 
DECLARE (CI, SI) ADDRESS INITIAL (1, 1), SEEN BYTE INITIAL (0);
DO WHILE SEEN < 30;
    DO WHILE CUBE(CI) < SQUARE(SI);
        CI = CI + 1;
    END;
    IF SQUARE(SI) <> CUBE(CI) THEN DO;
        CALL PRINT$NUMBER(SQUARE(SI));
        SEEN = SEEN + 1;
    END;
    SI = SI + 1;
END;
 
CALL BDOS(0,0);
EOF