Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
30
Task/Additive-primes/XPL0/additive-primes.xpl0
Normal file
30
Task/Additive-primes/XPL0/additive-primes.xpl0
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
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;
|
||||
];
|
||||
|
||||
func SumDigits(N); \Return the sum of the digits in N
|
||||
int N, Sum;
|
||||
[Sum:= 0;
|
||||
repeat N:= N/10;
|
||||
Sum:= Sum + rem(0);
|
||||
until N=0;
|
||||
return Sum;
|
||||
];
|
||||
|
||||
int Count, N;
|
||||
[Count:= 0;
|
||||
for N:= 0 to 500-1 do
|
||||
if IsPrime(N) & IsPrime(SumDigits(N)) then
|
||||
[IntOut(0, N);
|
||||
Count:= Count+1;
|
||||
if rem(Count/10) = 0 then CrLf(0) else ChOut(0, 9\tab\);
|
||||
];
|
||||
CrLf(0);
|
||||
IntOut(0, Count);
|
||||
Text(0, " additive primes found below 500.
|
||||
");
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue