29 lines
638 B
Text
29 lines
638 B
Text
func IsPrime(N); \Return 'true' if N is a prime number
|
|
int N, I;
|
|
[if N <= 1 then return false;
|
|
for I:= 2 to sqrt(N) do
|
|
if rem(N/I) = 0 then return false;
|
|
return true;
|
|
];
|
|
|
|
int Count, N, Sum, Prime;
|
|
[Text(0, "Prime Prime
|
|
count sum
|
|
");
|
|
Count:= 0; N:= 0; Sum:= 0;
|
|
for Prime:= 2 to 1000-1 do
|
|
if IsPrime(Prime) then
|
|
[N:= N+1;
|
|
Sum:= Sum + Prime;
|
|
if IsPrime(Sum) then
|
|
[Count:= Count+1;
|
|
IntOut(0, N);
|
|
ChOut(0, 9\tab\);
|
|
IntOut(0, Sum);
|
|
CrLf(0);
|
|
];
|
|
];
|
|
IntOut(0, Count);
|
|
Text(0, " prime sums of primes found below 1000.
|
|
");
|
|
]
|