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

Content added Content deleted
(Added Wren)
(Add Factor)
Line 1: Line 1:
{{draft task}}
{{draft task}}
Find all the numbers vhich digits are primes and sum of them is 13.
Find all the numbers vhich digits are primes and sum of them is 13.

=={{header|Factor}}==
<lang factor>USING: formatting io kernel math math.combinatorics
math.functions math.ranges sequences sequences.extras ;

: digits>number ( seq -- n ) reverse 0 [ 10^ * + ] reduce-index ;

"Numbers whose digits are prime and sum to 13:" print
{ 2 3 5 7 } 3 6 [a,b] [ selections [ sum 13 = ] filter ] with
map-concat [ digits>number ] map "%[%d, %]\n" printf</lang>
{{out}}
<pre>
Numbers whose digits are prime and sum to 13:
{ 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|Ring}}==
=={{header|Ring}}==
<lang ring>
<lang ring>