Borland Pascal Wiki
Borland Pascal Wiki
 This script page was blocked. The script was reviewed and it works perfectly so this page doesn't need anymore editing.

This script demonstrates the basic algorithm of determining whether a number is prime or not. It uses the the method of the wrong preposition, where the goal is to determine that the number is not prime. It uses a boolean variable for that.

var x,i:integer;
    IsPrime: boolean;
begin
write ('Type x: '); readln (x);
IsPrime:=true;
for i:=2 to x div 2-1 do
if x mod i = 0 then
IsPrime:=false;
if IsPrime then
write (x,' is prime.')
else
write (x,' is not prime.');
readln;
end.