This repository has been archived on 2024-12-25. You can view files and clone it, but cannot push or open issues or pull requests.
2024-03-10 20:32:51 +03:00

21 lines
545 B
ObjectPascal
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Алгоритм определения простоты числа
var
N: integer;
IsPrime: boolean;
begin
writeln('Введите число: ');
readln(N);
IsPrime := True;
for var i:=2 to round(sqrt(N)) do // если число составное, то один из его сомножителей <= (sqrt(N))
if N mod i = 0 then
begin
IsPrime := False;
break;
end;
if IsPrime then
writeln('Число ',N,' простое')
else writeln('Число ',N,' составное');
end.