Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Program TestPrime;
var num, count, remainder:integer;
begin
writeln('Input a number to check whether it is a prime? ');
readln(num);
count:= 2;
remainder:= 1;
while (count <= num) and (remainder = 1) do
begin
remainder := num mod count ;
count := count + 1;
end;
if remainder = 0 then
writeln('The number ', num, ' is not a prime number')
else
writeln('The number ', num, ' is a prime number')
end.
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more