# Write a program that checks if a user-supplied integer is prime. Pascal program

March 30, 2021 | education

| program zz1;

function Prost (a: longint): boolean;

var i: longint;

f: boolean;

begin

if a <2 then f: = false

else

begin

f: = true;

i: = 2;

while (i * i <= a) and f do // while the counter is less than the root of the number and there are no divisors

if a mod i = 0 then f: = false // if divisor, then not prime

else i: = i + 1;

end;

Prost: = f;

end;

var n: integer;

begin

writeln (‘Enter a natural number n =’); // enter a number from the keyboard

readln (n);

if Prost (n) then writeln (‘Simple’) // print the answer

else writeln (‘Not simple’);

end.

One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.