Amicable pairs: Difference between revisions
Content deleted Content added
m →{{header|Phix}}: added syntax colouring the hard way |
Not a robot (talk | contribs) Add PL/M |
||
Line 3,376: | Line 3,376: | ||
17296 18416 found after 2.240 seconds |
17296 18416 found after 2.240 seconds |
||
2.250 seconds total search time</pre> |
2.250 seconds total search time</pre> |
||
=={{header|PL/M}}== |
|||
<lang plm>100H: |
|||
/* CP/M CALLS */ |
|||
BDOS: PROCEDURE (FN, ARG); DECLARE FN BYTE, ARG ADDRESS; GO TO 5; END BDOS; |
|||
EXIT: PROCEDURE; CALL BDOS(0,0); END EXIT; |
|||
PRINT: PROCEDURE (S); DECLARE S ADDRESS; CALL BDOS(9,S); END PRINT; |
|||
/* PRINT A NUMBER */ |
|||
PRINT$NUMBER: PROCEDURE (N); |
|||
DECLARE S (6) 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 PRINT(P); |
|||
END PRINT$NUMBER; |
|||
/* CALCULATE SUMS OF PROPER DIVISORS */ |
|||
DECLARE DIV$SUM (20$001) ADDRESS; |
|||
DECLARE (I, J) ADDRESS; |
|||
DO I=2 TO 20$000; DIV$SUM(I) = 1; END; |
|||
DO I=2 TO 10$000; |
|||
DO J = I*2 TO 20$000 BY I; |
|||
DIV$SUM(J) = DIV$SUM(J) + I; |
|||
END; |
|||
END; |
|||
/* TEST EACH PAIR */ |
|||
DO I=2 TO 20$000; |
|||
DO J=I+1 TO 20$000; |
|||
IF DIV$SUM(I)=J AND DIV$SUM(J)=I THEN DO; |
|||
CALL PRINT$NUMBER(I); |
|||
CALL PRINT(.', $'); |
|||
CALL PRINT$NUMBER(J); |
|||
CALL PRINT(.(13,10,'$')); |
|||
END; |
|||
END; |
|||
END; |
|||
CALL EXIT; |
|||
EOF</lang> |
|||
{{out}} |
|||
<pre>220, 284 |
|||
1184, 1210 |
|||
2620, 2924 |
|||
5020, 5564 |
|||
6232, 6368 |
|||
10744, 10856 |
|||
12285, 14595 |
|||
17296, 18416</pre> |
|||
=={{header|PowerShell}}== |
=={{header|PowerShell}}== |