FANDOM


 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.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.