Primes whose sum of digits is 25: Difference between revisions

Added XPL0 example.
(Added 11l)
(Added XPL0 example.)
Line 2,198:
2,797 2,887 3,499 3,697 3,769 3,877
3,967 4,597 4,759 4,957 4,993
</pre>
 
=={{header|XPL0}}==
<lang XPL0>func IsPrime(N); \Return 'true' if N is prime
int N, I;
[if N <= 2 then return N = 2;
if (N&1) = 0 then \even >2\ return false;
for I:= 3 to sqrt(N) do
[if rem(N/I) = 0 then return false;
I:= I+1;
];
return true;
];
 
func SumDigits(N); \Return sum of digits in N
int N, Sum;
[Sum:= 0;
repeat N:= N/10;
Sum:= Sum + rem(0);
until N=0;
return Sum;
];
 
int Cnt, N;
[Cnt:= 0;
for N:= 2 to 5000-1 do
if IsPrime(N) & SumDigits(N) = 25 then
[IntOut(0, N);
Cnt:= Cnt+1;
if rem(Cnt/5) then ChOut(0, 9\tab\) else CrLf(0);
];
CrLf(0);
IntOut(0, Cnt);
Text(0, " primes whose sum of digits is 25.
");
]</lang>
 
{{out}}
<pre>
997 1699 1789 1879 1987
2689 2797 2887 3499 3697
3769 3877 3967 4597 4759
4957 4993
17 primes whose sum of digits is 25.
</pre>
772

edits