Numbers divisible by their individual digits, but not by the product of their digits.: Difference between revisions

→‎{{header|J}}: redo, with some comments
(→‎{{header|J}}: redo, with some comments)
Line 1,038:
 
=={{header|J}}==
<lang J> ([ #~ ((10 #.^:_1inv]) ((0:~:*/@[|]) *. *./@(0:=|)) ])"0) >:i.999</lang>
<pre>22 33 44 48 55 66 77 88 99 122 124 126 155 162 168 184 222 244 248 264 288 324 333 336 366 396 412 424 444 448 488 515 555 636 648 666 728 777 784 824 848 864 888 936 999</prelang>
{{out}}
 
<pre>22 33 44 48 55 66 77 88 99 122 124 126 155 162 168 184 222 244 248 264 288 324 333 336 366 396 412 424 444 448 488 515 555 636 648 666 728 777 784 824 848 864 888 936 999</pre>
<code>([ #~ ... ) >:i.999</code> filters the numbers based on the predicate (shown as '...' here).
 
<code>((10 #.inv]) ... ])"0</code> extracts a predicate value for each number, with the number's digits as the left argument and the number itself as the right argument.
 
<code>((0~:*/@[|]) * */@(0=|))</code> is true if the product of the digits does not evenly divide the number (<code>(0~:*/@[|])</code>) AND all of the digits individually evenly divide the number (<code>*/@(0=|)</code>).
 
=={{header|jq}}==
6,951

edits