Jump to content

Coprimes: Difference between revisions

Added XPL0 example.
(Added Algol 68)
(Added XPL0 example.)
Line 960:
[17, 23]
[18, 29]
</pre>
 
=={{header|XPL0}}==
<lang XPL0>func GCD(A, B); \Return greatest common divisor of A and B
int A, B;
[while A#B do
if A>B then A:= A-B
else B:= B-A;
return A;
];
 
int Input, N, A, B;
[Input:= [[21,15], [17,23], [36,12], [18,29], [60,15]];
for N:= 0 to 4 do
[A:= Input(N, 0); B:= Input(N, 1);
if GCD(A, B) = 1 then
[IntOut(0, A); ChOut(0, ^,); IntOut(0, B); CrLf(0)];
];
]</lang>
 
{{out}}
<pre>
17,23
18,29
</pre>
772

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.