Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Summarize-primes/XPL0/summarize-primes.xpl0
Normal file
29
Task/Summarize-primes/XPL0/summarize-primes.xpl0
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
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.
|
||||
");
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue