pascalabcnet/InstallerSamples/!Tutorial/06_ForWhileRepeat/algo1.pas
2025-10-14 21:21:47 +03:00

15 lines
505 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.

// Алгоритм определения простоты числа
begin
var N := ReadInteger('Введите число:');
var 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
Println('Число', N, 'простое') else Println('Число', N, 'составное');
end.