Var A:array[1..10000] of integer; i,NOD,NOK,k,N:integer; Begin Write('N = ');ReadLn(N); Write('Введите числа (',N,' шт.): '); For i:= 1 to N do Read(A[i]); {Поиск НОК} NOK:=abs(A[1]); For i:= 2 to N do if abs(A[i])<NOK then NOK:=abs(A[i]); if NOK = 0 then NOK:=1; Repeat k:=0; For i:= 1 to N do if A[i] mod NOK = 0 then k:=k+1; NOK:=NOK-1; Until k=N; WriteLn('NOK = ',NOK+1); {Поиск НОД} NOD:=A[1]; For i:= 2 to N do if abs(A[i])>NOD then NOD:=A[i]; Repeat k:=0; For i:= 1 to N do if NOD mod A[i] = 0 then k:=k+1; NOD:=NOD+1; Until k=N; WriteLn('NOD = ',NOD-1) End.
Function NOD(a, b: integer):integer; begin while a<>b do if a>b then a-=b else b-=a; result:=a; end;
begin var n:=readinteger('N ='); var a:=ReadArrInteger('Вводите: ', n); var prod1:=1; var prod:=a[0]; var nod1:=a[0]; for var i:=1 to n-1 do begin nod1:=NOD(nod1, a[i]); prod*=a[i]; end; for var i:=0 to n-2 do for var j:=i+1 to n-1 do prod1*=NOD(a[i], a[j]); write ('НОК: ', prod div prod1, '; НОД: ', nod1); end.
i,NOD,NOK,k,N:integer;
Begin
Write('N = ');ReadLn(N);
Write('Введите числа (',N,' шт.): ');
For i:= 1 to N do
Read(A[i]);
{Поиск НОК}
NOK:=abs(A[1]);
For i:= 2 to N do
if abs(A[i])<NOK then NOK:=abs(A[i]);
if NOK = 0 then NOK:=1;
Repeat
k:=0;
For i:= 1 to N do
if A[i] mod NOK = 0 then k:=k+1;
NOK:=NOK-1;
Until k=N;
WriteLn('NOK = ',NOK+1);
{Поиск НОД}
NOD:=A[1];
For i:= 2 to N do
if abs(A[i])>NOD then NOD:=A[i];
Repeat
k:=0;
For i:= 1 to N do
if NOD mod A[i] = 0 then k:=k+1;
NOD:=NOD+1;
Until k=N;
WriteLn('NOD = ',NOD-1)
End.
begin
while a<>b do if a>b then a-=b else b-=a;
result:=a;
end;
begin
var n:=readinteger('N =');
var a:=ReadArrInteger('Вводите: ', n);
var prod1:=1; var prod:=a[0]; var nod1:=a[0];
for var i:=1 to n-1 do
begin
nod1:=NOD(nod1, a[i]);
prod*=a[i];
end;
for var i:=0 to n-2 do for var j:=i+1 to n-1 do prod1*=NOD(a[i], a[j]);
write ('НОК: ', prod div prod1, '; НОД: ', nod1);
end.