Special pythagorean triplet: Difference between revisions

→‎{{header|PL/M}}: Remove redundant test and slight simplification
(→‎{{header|ALGOL 68}}: Stop after a solution is found.)
(→‎{{header|PL/M}}: Remove redundant test and slight simplification)
Line 126:
 
=={{header|PL/M}}==
Based on the XPL0 solution.
{{Trans|XPL0}}
<br>As the original 8080 PL/M compiler only has unsigned 8 and 16 bit integer arithmetic, the PL/M [https://www.rosettacode.org/wiki/Long_multiplication long multiplication routines] and also a square root routine based that in the PL/M sample for the [https://www.rosettacode.org/wiki/Frobenius_numbers Frobenius Numbers task] are used - which makes this somewhat longer than it would otherwose be...
<lang pli>100H: /* FIND THE PYTHAGOREAN TRIPLET A, B, C WHERE A + B + C = 1000 */
 
Line 243:
/* A, B AND C: A = M2 - N2, B = 2MN, C = M2 + N2 TO CALCULATE */
/* A + B + C = M2 - N2 + 2MN + M2 + N2 = 2( M2 + MN ) = 2M( M + N )*/
IF ( 2 * M * ( M + N ) ) = 1000 AND M > N500 THEN DO;
M2 = M * M;
N2 = N * N;
3,049

edits