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

m
→‎{{header|REXX}}: added the computer programming language REXX.
(Added Algol W)
m (→‎{{header|REXX}}: added the computer programming language REXX.)
Line 154:
{{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>
 
=={{header|REXX}}==
<lang rexx>/*REXX program finds and displays all numbers whose digits are prime and sum to 13. */
LO= 337; HI= 322222 /*define the low and high range for #s.*/
pDigs= 2357; #= 0 /*define the prime digits; number count*/
$= /*variable to hold the list of #s found*/
do j=LO for HI-LO+1 /*search for numbers in this range. */
if verify(j, pDigs) \== 0 then iterate /*J must be comprised of prime digits.*/
parse var j a 2 b 3 '' -1 z /*parse: 1st, 2nd, & last decimal digs.*/
sum= a + b + z /*sum: " " " " " " */
do k=3 for length(j)-3 /*only need to sum #s with #digits ≥ 4 */
sum= sum + substr(j, k, 1) /*sum some middle decimal digits of J.*/
end /*k*/
if sum\==13 then iterate /*Sum not equal to 13? Then skip this #*/
#= # + 1 /*bump count of numbers found so far. */
$= $ j /*append the number to the output list.*/
end /*j*/
/*stick a fork in it, we're all done. */
say strip($); say /*display the output list to the term. */
say # ' numbers found.' /* " " count of #s " " " */</lang>
{{out|output|text=&nbsp; when using the internal default inputs:}}
<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
 
43 numbers found.
</pre>
 
=={{header|Ring}}==