Prévia do material em texto
(* gcd.pas
Autor: Angelo de Oliveira
Objetivo: mostrar a implmentacao do algoritmo de euclides para
se determinar o maior divisor comum entre dois numeros.
*)
Program gdc;
Uses Crt, Math;
Var x, y: Integer;
Function gcd(u, v: Integer) : Integer;
Var t: Integer;
Begin
If u < v Then
t := u
Else
t := v;
While ((u mod t <> 0) Or (v mod t <> 0)) Do
t := t - 1;
gcd := t;
End;
Begin
ClrScr;
Begin
WriteLn('Digite dois numeros inteiros: ');
ReadLn(x, y);
WriteLn('x = ', x, ' y = ', y, ' gdc = ', gcd(abs(x), abs(y)));
End;
End.