Numbers with prime digits whose sum is 13: Difference between revisions

Added XPL0 example
(→‎{{header|Wren}}: Stack corruption bug now fixed.)
(Added XPL0 example)
Line 448:
Those numbers whose digits are all prime and sum to 13 are:
[337, 355, 373, 535, 553, 733, 2227, 2272, 2335, 2353, 2533, 2722, 3235, 3253, 3325, 3352, 3523, 3532, 5233, 5323, 5332, 7222, 22225, 22252, 22333, 22522, 23233, 23323, 23332, 25222, 32233, 32323, 32332, 33223, 33232, 33322, 52222, 222223, 222232, 222322, 223222, 232222, 322222]
</pre>
 
=={{header|XPL0}}==
<lang XPL0>
int N, M, S, D;
[for N:= 2 to 322222 do
[M:= N; S:= 0;
repeat M:= M/10; \get digit D
D:= remainder(0);
case D of
2, 3, 5, 7:
[S:= S+D;
if S=13 and M=0 \all digits included\ then
[IntOut(0, N); ChOut(0, ^ )];
]
other M:= 0; \digit not prime so exit repeat loop
until M=0; \all digits in N tested or digit not prime
];
]</lang>
 
{{out}}
<pre>
337 355 373 535 553 733 2227 2272 2335 2353 2533 2722 3235 3253 3325 3352 3523 3532 5233 5323 5332 7222 22225 22252 22333 22522 23233 23323 23332 25222 32233 32323 32332 33223 33232 33322 52222 222223 222232 222322 223222 232222 322222
</pre>
772

edits