16 lines
390 B
Text
16 lines
390 B
Text
include c:\cxpl\codes; \intrinsic 'code' declarations
|
|
|
|
func Prime(N); \Return 'true' if N is a prime number
|
|
int N;
|
|
int I;
|
|
[if N <= 1 then return false;
|
|
for I:= 3 to sqrt(N) do
|
|
if rem(N/I) = 0 then return false;
|
|
return true;
|
|
]; \Prime
|
|
|
|
int Num;
|
|
repeat Num:= IntIn(0);
|
|
Text(0, if Prime(Num) then "is " else "not ");
|
|
Text(0, "prime^M^J");
|
|
until Num = 0
|