How to resolve the algorithm Largest proper divisor of n step by step in the PL/M programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Largest proper divisor of n step by step in the PL/M programming language

Table of Contents

Problem Statement

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Largest proper divisor of n step by step in the PL/M programming language

Source code in the pl/m programming language

100H:
BDOS: PROCEDURE (FN, ARG); DECLARE FN BYTE, ARG ADDRESS; GO TO 5; END BDOS;
EXIT: PROCEDURE; CALL BDOS(0,0); END EXIT;
PUT$CHAR: PROCEDURE (CH); DECLARE CH BYTE; CALL BDOS(2,CH); END PUT$CHAR;
PRINT: PROCEDURE (S); DECLARE S ADDRESS; CALL BDOS(9,S); END PRINT;

PRINT$3: PROCEDURE (N);
    DECLARE N BYTE;
    CALL PUT$CHAR(' ');
    IF N>9
        THEN CALL PUT$CHAR('0' + N/10);
        ELSE CALL PUT$CHAR(' ');
    CALL PUT$CHAR('0' + N MOD 10);
END PRINT$3;

LPD: PROCEDURE (N) BYTE;
    DECLARE (N, I) BYTE;
    IF N <= 1 THEN RETURN 1;
    I = N-1;
    DO WHILE I >= 1;
        IF N MOD I = 0 THEN RETURN I;
        I = I - 1;
    END;
END LPD;

DECLARE I BYTE;
DO I=1 TO 100;
    CALL PRINT$3(LPD(I));
    IF I MOD 10 = 0 THEN CALL PRINT(.(13,10,'$'));
END;
CALL EXIT;
EOF

  

You may also check:How to resolve the algorithm Self-describing numbers step by step in the Ring programming language
You may also check:How to resolve the algorithm Pig the dice game step by step in the Wren programming language
You may also check:How to resolve the algorithm Monte Carlo methods step by step in the MATLAB programming language
You may also check:How to resolve the algorithm Box the compass step by step in the Scala programming language
You may also check:How to resolve the algorithm Pascal's triangle step by step in the Common Lisp programming language