Primality by Wilson's theorem: Difference between revisions
→{{header|Polyglot:PL/I and PL/M}}: Use new include file
(→{{header|Polyglot:PL/I and PL/M}}: Minor simplification) |
(→{{header|Polyglot:PL/I and PL/M}}: Use new include file) |
||
Line 1,391:
{{works with|8080 PL/M Compiler}} ... under CP/M (or an emulator)
Should work with many PL/I implementations.
<br>
The PL/I include file "pg.inc" can be found on the [[Polyglot:PL/I and PL/M]] page.
Note the use of text in column 81 onwards to hide the PL/I specifics from the PL/M compiler.<lang pli>
<lang pli>/* PRIMALITY BY WILSON'S THEOREM */
wilson_100H: procedure options (main);
%include 'pg.inc';
/* PL/M DEFINITIONS: CP/M BDOS SYSTEM CALL AND CONSOLE I/O ROUTINES, ETC. */ /*
DECLARE BINARY LITERALLY 'ADDRESS', CHARACTER LITERALLY 'BYTE';
DECLARE
DECLARE FN BYTE, ARG ADDRESS; GOTO 5; END;
PRCHAR: PROCEDURE( C ); DECLARE C CHARACTER; PUT edit(c)(a(1)) /* */ /*▼
BDOS: PROCEDURE( FN, ARG ); DECLARE FN BYTE, ARG ADDRESS; GOTO 5; END;
END PRCHAR;▼
PRNUMBER: PROCEDURE( N );
DECLARE N ADDRESS;
DECLARE V ADDRESS, N$STR( 6 ) BYTE, W BYTE;
N$STR( W := W - 1 ) = '0' + ( ( V := N ) MOD 10
DO WHILE( ( V
CALL BDOS( 9,
▲ N$STR( W := W - 1 ) = '0' + ( V MOD 10 );
▲ END;
END PRNUMBER;
MODF: PROCEDURE( A, B )ADDRESS;
DECLARE ( A, B )ADDRESS;
RETURN( A MOD B );
/* END LANGUAGE DEFINITIONS */
/* TASK */
Line 1,426 ⟶ 1,433:
FMODP = 1;
DO I = 2 TO N - 1;
FMODP =
END;
RETURN ( FMODP = N - 1 );
Line 1,439 ⟶ 1,444:
END;
END;
EOF: end wilson_100H ;</lang>
{{out}}
<pre>
|