PROGRAM ExPrime;
USES Crt;
VAR
a :Integer;
ok :Boolean;
ans : Char;
FUNCTION isPrime(x:Integer):Boolean;
VAR
i: Integer;
BEGIN
FOR i:= 2 TO x-1 DO
IF (x MOD i =0) THEN
BEGIN
isPrime:=FALSE;
Exit
END
ELSE isPrime:= TRUE
END;
BEGIN
ClrScr;
writeln('Program find Prime number');
writeln('By Ong-at ');
REPEAT
Write('Enter a number :'); ReadLn(a);
ok:=isPrime(a);
IF ok THen WriteLn('number ',a:6 ,' is prime.')
ELSE
WriteLn('number ',a:6 ,' is not prime.');
Write('Do you want to continue (Y/N) : '); ReadLn(ans);
ans:=Upcase(ans);
UNTIL ans ='N';
{ REPEAT UNTIL KeyPressed}
END.
|