How to resolve the algorithm Square but not cube step by step in the MAD programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Square but not cube step by step in the MAD programming language

Table of Contents

Problem Statement

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.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Square but not cube step by step in the MAD programming language

Source code in the mad programming language

            NORMAL MODE IS INTEGER
            
            CUBE=1
            NCUBE=1
            SQR=1
            NSQR=1
            SEEN=0
            
SQRLP       SQR = NSQR*NSQR
CUBELP      WHENEVER SQR.G.CUBE
                NCUBE = NCUBE+1
                CUBE = NCUBE*NCUBE*NCUBE
                TRANSFER TO CUBELP
            END OF CONDITIONAL
            WHENEVER SQR.NE.CUBE
                SEEN = SEEN+1
                PRINT FORMAT FMT,SQR
            END OF CONDITIONAL
            NSQR = NSQR+1
            WHENEVER SEEN.L.30, TRANSFER TO SQRLP
            
            VECTOR VALUES FMT = $I4*$
            END OF PROGRAM

  

You may also check:How to resolve the algorithm Primality by Wilson's theorem step by step in the Pascal programming language
You may also check:How to resolve the algorithm Loops/Wrong ranges step by step in the C++ programming language
You may also check:How to resolve the algorithm Sierpinski triangle step by step in the Racket programming language
You may also check:How to resolve the algorithm Approximate equality step by step in the Wren programming language
You may also check:How to resolve the algorithm Bulls and cows/Player step by step in the Common Lisp programming language