Greatest common divisor: Difference between revisions

Content added Content deleted
(→‎Uiua: Fixed header)
(PascalABC.NET)
Line 5,256: Line 5,256:
GCD(49865, 69811): 9973 (recursive)
GCD(49865, 69811): 9973 (recursive)
GCD(49865, 69811): 9973 (binary)
GCD(49865, 69811): 9973 (binary)
</pre>

=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
function GCD(a,b: integer): integer;
begin
while b > 0 do
(a,b) := (b,a mod b);
Result := a;
end;

function GCDRec(a,b: integer): integer;
begin
if b = 0 then
Result := a
else Result := GCDRec(b, a mod b);
end;

begin
Println(GCD(72,30),GCD(72,30));
Println(GCD(49865, 69811),GCD(49865, 69811));
end.
</syntaxhighlight>
{{out}}
<pre>
6 6
9973 9973
</pre>
</pre>