program BAI5;
var
inputFile, outputFile: Text;
n, i, currentDivisorCount, maxDivisorCount, maxDivisorNumber: Integer;
function Uocso(number: Integer): Integer;
var
cnt, i: Integer;
begin
cnt := 0;
for i := 1 to number do
begin
if (number mod i = 0) then
cnt := cnt + 1;
end;
Uocso := cnt;
end;
begin
Assign(inputFile, 'BAI5.INP');
Assign(outputFile, 'BAI5.OUT');
reset(inputFile);
rewrite(outputFile);
readln(inputFile, n);
maxDivisorCount := 0;
maxDivisorNumber := 0;
for i := 1 to n do
begin
currentDivisorCount := Uocso(i);
if (currentDivisorCount > maxDivisorCount) then
begin
maxDivisorCount := currentDivisorCount;
maxDivisorNumber := i;
end;
end;
writeln(outputFile, maxDivisorNumber);
close(inputFile);
close(outputFile);
end.
Em thử chạy chương trình Pascal này nhé. Cho a 5 sao nha